<template>
  <div class="count" id="draggle-area">
    <!--客开新增弹窗 逻辑原先保持一致-->
    <el-dialog
      title="选择密级"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :visible.sync="
        this.dialogVisible &&
        this.$store.state.isredNet &&
        this.$store.state.isWriteEamil
      "
      :show-close="false"
      width="30%"
    >
      <el-select
        v-model="msg.secretTypeId"
        placeholder="请选择"
        @change="MailFileSecretVerify"
        @visible-change="cct"
        class="secretArrow"
      >
        <el-option
          v-for="item in secretTypeIdList"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        >
        </el-option>
      </el-select>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="small"
          round
          type="default"
          @click="handleSelectSecretConcel"
          >取消</el-button
        >
        <el-button size="small" round type="primary" @click="selectSecretType"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <div
      v-show="
        !(
          this.dialogVisible &&
          this.$store.state.isredNet &&
          this.$store.state.isWriteEamil
        )
      "
      style="
        border-radius: 4px;
        background: white;
        border: 1px solid #ebeef0;
        margin: 15px;
        padding: 15px;
        height: 92%;
        overflow: auto;
      "
    >
      <div class="flieupload">
        <el-upload
          style="display: none"
          class="avatar-uploader"
          :action="serverUrl"
          ref="upload"
          name="file"
          :headers="header"
          :auto-upload="false"
          :show-file-list="false"
          :multiple="true"
          :http-request="uploadFile"
          :on-success="uploadflieSuccess"
          :on-change="beforeFeedBackExports"
          :on-error="uploadflieError"
          :on-progress="uploadVideoProcess"
          :before-upload="beforeflieUpload"
        >
        </el-upload>
      </div>
      <el-form
        ref="form"
        label-width="5em"
        :model="msg"
        class="demo-form-inline"
        size="mini"
        style="height: 100%; position: relative"
      >
        <div style="padding-bottom: 15px">
          <el-button
            type="danger"
            round
            icon="el-icon-position"
            size="mini"
            @click="send"
            >发 送 邮 件</el-button
          >
          <el-button
            type="primary"
            round
            icon="el-icon-folder-add"
            size="mini"
            @click="save"
            >保 存 草 稿
          </el-button>
          <el-button
            round
            class="closeBt"
            size="mini"
            @click="cancelSave"
            icon="el-icon-close"
          >
            <!-- @click="refnav" -->
          </el-button>
        </div>
        <el-row class="the-theme">
          <el-col :span="24">
            <!--主题-->
            <el-form-item label="主题  " required>
              <el-tooltip
                :disabled="msg.subject == '' || msg.subject == null"
                class="item"
                effect="dark"
                :content="msg.subject"
                placement="top-start"
              >
                <el-input
                  v-model="msg.subject"
                  placeholder="邮件主题"
                ></el-input>
              </el-tooltip>
            </el-form-item>
          </el-col>
          <el-col v-show="this.$store.state.isredNet" :span="4">
            <el-form-item label="密级" required>
                            <div id="secretType">
                              <el-select v-if="mailSecret.length > 0" @change="secretTypeChange" v-model="msg.secretlevel" placeholder="请选择"  @visible-change="cct">
                                           <el-option
                                                   v-for="item in mailSecret"
                                                   :key="item.id"
                                                   :label="item.name"
                                                   :value="item.value">
                                           </el-option>
            <!-- <slectli  v-for="item in secretTypeIdList"
                                          :key="item.id"
                                          :label="item.name"
                                          :value="item.id">
                                </slectli> -->
                            </el-select>
                            </div>
                        </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <!-- 收件人-->
          <el-col :span="24" class="the-recipient">
            <el-form-item label="收件人" required class="select-user-form">
              <!-- lyy :disabled="msg.receiversStr == '' || msg.receiversStr == null" -->
              <el-tooltip
                class="item"
                :disabled="true"
                effect="dark"
                :content="msg.receiversStr.toString()"
                placement="bottom"
              >
<!--                <el-input clearable-->
<!--                          v-model="msg.receiversStr"-->
<!--                          placeholder="收件人"-->
<!--                          @focus="setlepeo($event,'receivers')"-->
<!--                          suffix-icon="el-icon-user-solid"></el-input> -->

                <el-select
                  ref="receiver"
                  v-model="receiversStr"
                  placeholder="收件人"
                  multiple
                  filterable
                  default-first-option
                  remote
                  :filter-method="selectBlur"
                  @clear="selectClear"
                  @remove-tag="removeReceiverTag"
                  @change="selectChange"
                  class="select-user"
                  icon="el-icon-user-solid"
                >
                <!-- 屏蔽邮件审批 :popper-append-to-body="false" -->
                  <!-- @focus="focusSearch" -->
                  <el-option
                    v-for="(item, index) in receiversOptions"
                    :key="index"
                    :value="item.memberId || item.id"
                    :label="item.value"
                    @click="getOption(item.memberId)"
                  >
                    {{ item.operationName }}
                  </el-option>
                </el-select>
              </el-tooltip>
              <i
                class="el-icon-user-solid position-icon"
                @click.stop="setlepeo($event, 'receivers')"
              ></i>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!--     抄送人       -->
          <el-col :span="24" class="copy-people">
            <el-form-item label="抄送" class="select-user-form">
              <!-- lyy  :disabled="
                                msg.copyReceiversStr == '' || msg.copyReceiversStr == null
                            "-->
              <el-tooltip
                class="item"
                :disabled="true"
                effect="dark"
                :content="msg.copyReceiversStr.toString()"
                placement="bottom"
              >
                <!-- <el-input clearable
                          v-model="msg.copyReceiversStr"
                          placeholder="抄送人"
                          @focus="setlepeo($event,'copyReceivers')"
                          suffix-icon="el-icon-user-solid"></el-input> -->
                <el-select
                  ref="copyReceiver"
                  v-model="copyReceiversStr"
                  placeholder="抄送人"
                  multiple
                  filterable
                  default-first-option
                  remote
                  :popper-append-to-body="false"
                  :filter-method="selectBlurCopyReceiver"
                  @clear="selectClearCopyReceiver"
                  @remove-tag="removeCopyReceiverTag"
                  @change="selectChangeCopyReceiver"
                  class="select-user"
                  icon="el-icon-user-solid"
                >
                  <!--lyy  @focus="copyReceiversFocusSearch" -->
                  <el-option
                    v-for="(item, index) in copyReceiversOptions"
                    :key="index"
                    :value="item.memberId || item.id"
                    :label="item.value"
                  >
                    {{ item.operationName }}
                  </el-option>
                </el-select>
              </el-tooltip>
              <i
                class="el-icon-user-solid position-icon"
                @click.stop="setlepeo($event, 'copyReceivers')"
              ></i>
            </el-form-item>
          </el-col>
          <!--      密级 -->
          <!-- <p v-show="false" class="emailsecretTypeId">{{ msg.secretTypeId }}</p>
          <el-col v-show="this.$store.state.isredNet" :span="4">
            <el-form-item label="密级">
                            <div id="secretType">
                              <el-select v-model="msg.secretTypeId" placeholder="请选择" @change="MailFileSecretVerify" @visible-change="cct">
                                           <el-option
                                                   v-for="item in secretTypeIdList"
                                                   :key="item.id"
                                                   :label="item.name"
                                                   :value="item.id">
                                           </el-option>
            <slectli  v-for="item in secretTypeIdList"
                                          :key="item.id"
                                          :label="item.name"
                                          :value="item.id">
                                </slectli>
                            </el-select>
                            </div>
                        </el-form-item>
          </el-col> -->
        </el-row>
        <el-row>
          <!--     密送       -->
          <el-col :span="24" class="copy-people">
            <el-form-item label="密送" class="select-user-form">
              <!-- lyy  :disabled="
                                msg.copyReceiversStr == '' || msg.copyReceiversStr == null
                            "-->
              <el-tooltip
                class="item"
                :disabled="true"
                effect="dark"
                :content="msg.secretReceiversStr.toString()"
                placement="bottom"
              >
                <!-- <el-input clearable
                          v-model="msg.copyReceiversStr"
                          placeholder="抄送人"
                          @focus="setlepeo($event,'copyReceivers')"
                          suffix-icon="el-icon-user-solid"></el-input> -->
                <el-select
                  ref="receiversStr"
                  v-model="secretReceiversStr"
                  placeholder="密送人"
                  multiple
                  filterable
                  default-first-option
                  remote
                  :popper-append-to-body="false"
                  :filter-method="selectBlurSecretReceivers"
                  @remove-tag="removeSecretReceiversTag"
                  @change="selectChangeSecretReceivers"
                  class="select-user"
                  icon="el-icon-user-solid"
                >
                  <!--lyy  @focus="copyReceiversFocusSearch" -->
                  <el-option
                    v-for="(item, index) in secretReceiversOptions"
                    :key="index"
                    :value="item.memberId || item.id"
                    :label="item.value"
                  >
                    {{ item.operationName }}
                  </el-option>
                </el-select>
              </el-tooltip>
              <i
                class="el-icon-user-solid position-icon"
                @click.stop="setlepeo($event, 'secretReceivers')"
              ></i>
            </el-form-item>
          </el-col>
          <!--      密级 -->
          <p v-show="false" class="emailsecretTypeId">{{ msg.secretTypeId }}</p>
        </el-row>
        <template>
          <!--        <el-row>-->
          <!--          &lt;!&ndash;密级调整位置 modify yangyanhua&ndash;&gt;-->
          <!--          <el-col v-show="this.$store.state.isredNet" :span="4">-->
          <!--            <el-form-item label="密级" required>-->
          <!--              &lt;!&ndash; <div id="secretType"> &ndash;&gt;-->
          <!--              <el-select-->
          <!--                v-model="msg.secretTypeId"-->
          <!--                placeholder="请选择"-->
          <!--                @change="MailFileSecretVerify"-->
          <!--                @visible-change="cct"-->
          <!--              >-->
          <!--                <slectli-->
          <!--                  v-for="item in secretTypeIdList"-->
          <!--                  :key="item.id"-->
          <!--                  :label="item.name"-->
          <!--                  :value="item.id"-->
          <!--                >-->
          <!--                </slectli>-->
          <!--              </el-select>-->
          <!--              &lt;!&ndash; </div> &ndash;&gt;-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->

          <!--          <el-col-->
          <!--            :span="8"-->
          <!--            v-if="(msg.kuaWangdis && this.$store.state.isredNet) || msg.kuaWang"-->
          <!--          >-->
          <!--            <el-form-item-->
          <!--              label="审批人"-->
          <!--              class="select-user-form"-->
          <!--              label-width="100px"-->
          <!--              required-->
          <!--            >-->
          <!--              &lt;!&ndash; lyy :disabled="msg.approverStr == '' || msg.approverStr == null" &ndash;&gt;-->
          <!--              <el-tooltip-->
          <!--                class="item"-->
          <!--                :disabled="true"-->
          <!--                effect="dark"-->
          <!--                :content="msg.approverStr.toString()"-->
          <!--                placement="bottom"-->
          <!--              >-->
          <!--                &lt;!&ndash; <el-input clearable-->
          <!--                          v-model="msg.approverStr"-->
          <!--                          placeholder="审批人"-->
          <!--                          @focus="selectapprover($event)"-->
          <!--                          suffix-icon="el-icon-user-solid"></el-input> &ndash;&gt;-->
          <!--                <el-select-->
          <!--                  ref="approver"-->
          <!--                  v-model="approverStr"-->
          <!--                  placeholder="审批人"-->
          <!--                  multiple-->
          <!--                  filterable-->
          <!--                  remote-->
          <!--                  default-first-option-->
          <!--                  :multiple-limit="3"-->
          <!--                  :filter-method="selectBlurApprover"-->
          <!--                  @clear="selectClearApprover"-->
          <!--                  @change="selectChangeApprover"-->
          <!--                  @remove-tag="removeApproveTag"-->
          <!--                  class="select-user"-->
          <!--                  icon="el-icon-user-solid"-->
          <!--                >-->
          <!--                  &lt;!&ndash;lyy @focus="approverFocusSearch"  &ndash;&gt;-->
          <!--                  <el-option-->
          <!--                    v-for="(item, index) in approverOptions"-->
          <!--                    :key="index"-->
          <!--                    :value="item.memberId || item.id"-->
          <!--                    :label="item.value"-->
          <!--                  >-->
          <!--                    {{ item.operationName }}-->
          <!--                  </el-option>-->
          <!--                </el-select>-->
          <!--              </el-tooltip>-->
          <!--              <i-->
          <!--                class="el-icon-user-solid position-icon"-->
          <!--                @click.stop="selectapprover($event)"-->
          <!--              ></i>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->

          <!--          &lt;!&ndash;跨网&ndash;&gt;-->
          <!--          &lt;!&ndash; v-show="false" &ndash;&gt;-->
          <!--          <el-col :span="3" align="left" v-if="isKuaWangShow">-->
          <!--            <el-form-item label-width="0">-->
          <!--              <keep-alive>-->
          <!--                <el-checkbox-->
          <!--                  :disabled="msg.kuaWangdis && this.$store.state.isredNet"-->
          <!--                  v-model="msg.kuaWang"-->
          <!--                  ref="iskw"-->
          <!--                  style="margin-left: 38px"-->
          <!--                  :key="key"-->
          <!--                  >是否跨网-->
          <!--                </el-checkbox>-->
          <!--              </keep-alive>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          &lt;!&ndash;      定时发送      &ndash;&gt;-->
          <!--          <el-col :span="8">-->
          <!--            <div style="height: 2em">-->
          <!--              <el-form-item label-width="5">-->
          <!--                <el-checkbox-->
          <!--                  v-model="msg.timedTask"-->
          <!--                  style="margin-left: 38px"-->
          <!--                  :disabled="msg.kuaWang"-->
          <!--                >-->
          <!--                  定时发送</el-checkbox-->
          <!--                >-->
          <!--                <el-date-picker-->
          <!--                  :picker-options="pickerOptions"-->
          <!--                  v-show="msg.timedTask"-->
          <!--                  style="margin-left: 10px; width: 30%; padding: 0 30px 0 8px"-->
          <!--                  v-model="msg.timingDate"-->
          <!--                  type="datetime"-->
          <!--                  value-format="yyyy-MM-dd HH:mm:ss"-->
          <!--                  placeholder="选择发送时间"-->
          <!--                >-->
          <!--                </el-date-picker>-->
          <!--              </el-form-item>-->
          <!--            </div>-->
          <!--          </el-col>-->
          <!--          &lt;!&ndash;            &ndash;&gt;-->
          <!--        </el-row>-->
        </template>
        <div
          class="uploadbox"
          v-loading="loading"
          style="min-height: 40px !important"
          :element-loading-text="percentage"
          element-loading-spinner="el-icon-upload"
          element-loading-background="rgba(255,255,255,0.9 )"
        >
          <div style="margin-top: 5px">
            <i
              class="el-icon-paperclip"
              style="margin-left: 8px; color: #3d3d3d; font-size: 18px"
              ><span style="font-size: 14px; margin-left: 0.5em">
                <el-button type="text" size="mini" @click="uploadfile"
                  >上传文件</el-button
                ><span style="color: #999999; font-size: 12px"></span> </span
            ></i>
          </div>
          <div class="uploadflie">
            <el-row v-for="(i, n) in fileList" :key="i.fileUrl">
              <div>
                <el-col :span="6" >
                  <el-tooltip
                    class="item"
                    effect="dark"
                    :content="i.filename"
                    placement="top"
                  >
                    <div
                      style="
                        width: 97%;
                        margin: auto;
                        height: 65px;
                        background: #efefef;
                        border-radius: 4px;
                        display: flex;
                        margin-bottom: 10px;
                      "
                    >
                      <div
                        style="
                          width: 20%;
                          display: flex;
                          align-items: center;
                          justify-content: center;
                        "
                      >
                        <img
                          style="width: 64%"
                          :src="
                            '/seeyon/common/images/attachmentICON/' + i.icon
                          "
                        />
                      </div>
                      <div
                        style="width: 80%; position: relative; color: #484848"
                      >
                        <i
                          class="el-icon-download hand"
                          style="position: absolute; bottom: 5px; right: 30px"
                          @click="downflie(i)"
                        ></i>
                        <i
                          class="el-icon-delete hand"
                          style="position: absolute; bottom: 5px; right: 5px"
                          @click="delflie(n)"
                        ></i>
                        <p
                          style="
                            margin: 0.5em;
                            overflow: hidden;
                            white-space: nowrap;
                            text-overflow: ellipsis;
                          "
                        >
                          {{ i.filename }}
                        </p>
                        <span
                          style="margin: 0 1em; font-size: 14px; color: #b1b3b6"
                          >{{ i.size }}</span
                        >
                      </div>
                    </div>
                  </el-tooltip>
                </el-col>
                
                  <el-col :span="6" style="margin-top:20px">
                    <el-form-item label="密级" required>
                                    <div id="secretType">
                                      <el-select v-model="i.secretLevel" placeholder="请选择" @visible-change="cct">
                                                  <el-option
                                                          v-for="item in fileSecret"
                                                          :key="item.sort"
                                                          :label="item.name"
                                                          :value="item.value">
                                                  </el-option>
                    <!-- <slectli  v-for="item in secretTypeIdList"
                                                  :key="item.id"
                                                  :label="item.name"
                                                  :value="item.id">
                                        </slectli> -->
                                    </el-select>
                                    </div>
                                </el-form-item>
                  </el-col>
              </div>
            </el-row>
          </div>
        </div>

        <div class="fuwenben" style="margin-top: 10px; height: 80%">
          <el-upload
            style="display: none"
            class="avatar-uploader"
            :action="serverUrl"
            name="file"
            :headers="header"
            :show-file-list="false"
            list-type="picture"
            :multiple="true"
            :on-success="uploadSuccess"
            :on-error="uploadError"
            :before-upload="beforeUpload"
          >
          </el-upload>
          <vue-ueditor-wrap
            v-if="isshow"
            v-model="msg.content"
            :config="myConfig"
          ></vue-ueditor-wrap>
        </div>
        <!--                <div style="text-align: right;margin-top: 10px">-->
        <!--                    <el-button type="primary" plain size="mini" @click="save" >保 存 草 稿</el-button>-->
        <!--                    <el-button type="danger" plain size="mini" @click="send">发 送 邮 件</el-button>-->

        <!--                </div>-->
      </el-form>
    </div>
  </div>
</template>

<script>
import api from "@/api/api";
import slectli from "../components/slectli";
import VueUeditorWrap from "vue-ueditor-wrap";

export default {
  name: "editor",
  components: { slectli, VueUeditorWrap },
  beforeRouteLeave(to, from, next) {
    //点击刷新按钮，弹出是否保存草稿，需要将标志重新恢复初值
    if (this.$store.state.isWriteEamil) {
      this.$store.commit("setWriteEamil", false);
    }
    if (this.sendtie == false && !this.dialogVisible) {
      const answer = window.confirm("是否保存草稿？");
      if (answer == true) {
        if (!this.jycs()) {
            return false;
          }
        // 判断当邮件附件正在上传时，不能保存草稿
        if (this.percentage != 0 && !this.ifFileUploaded) {
          next(false);
          document.querySelector(".mid").style.display = "none";
          document.querySelector(".resize").style.display = "none";
          document.querySelector(".right").style.width = "auto";
          return this.$message.warning("文件还在上传中...");
        }
         
        this.saves();
      } else {
        // api
        //   .cancelAutosaveApi(this.firstAutosaveTime, this.msg.affairId)
        //   .then((res) => {
        //     console.log("执行了取消自动保存接口，并且拿到了详情值");
        //     this.$store.commit("changeCancelSaveDraftRandom");
        //     next();
        //   });
        this.$store.commit("changeCancelSaveDraftRandom");
        next();
      }
    }
    next();
  },
  data() {
    return {
      // lyy start
      // 收件人
      receiverOptionList: [],
      receiversStr: [],
      copyReceiversStr: [],
      approverStr: [],
      sendFlag: true,
      //   lyy end
      receiversOptions: [], //收件人
      copyReceiversOptions: [], //抄送人人
      secretReceiversStr: [], //密送人
      secretReceiversOptions:[], //密送人人
      approverOptions: [], //审批人
      //上传文件遮罩层
      loading: false,
      isshow: false,
      //编辑器的配置项初始化
      myConfig: {
        forceInit: true,
        enableAutoSave: false,
        // 编辑器不自动被内容撑高
        autoHeightEnabled: false,
        // 初始容器高度
        initialFrameHeight: 680,
        // 初始容器宽度
        initialFrameWidth: "100%",
        // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
        serverUrl: "",
        // UEditor 资源文件的存放路径，如果你使用的是 vue-cli 生成的项目，通常不需要设置该选项，vue-ueditor-wrap 会自动处理常见的情况，如果需要特殊配置，参考下方的常见问题2

        // '/seeyon/apps_res/plugin/newInternalmail//UE/' 为打包地址
        //  本地实际地址为'/UE/'
        UEDITOR_HOME_URL: "./UE/",
        // UEDITOR_HOME_URL: '/UE/',
        toolbars: [
          [
            "fullscreen",
            "source",
            "|",
            "undo",
            "redo",
            "|",
            "bold",
            "italic",
            "underline",
            "fontborder",
            "strikethrough",
            "superscript",
            "subscript",
            "removeformat",
            "formatmatch",
            "autotypeset",
            "blockquote",
            "pasteplain",
            "|",
            "forecolor",
            "backcolor",
            "insertorderedlist",
            "insertunorderedlist",
            "selectall",
            "cleardoc",
            "|",
            "rowspacingtop",
            "rowspacingbottom",
            "lineheight",
            "|",
            "customstyle",
            "paragraph",
            "fontfamily",
            "fontsize",
            "|",
            "directionalityltr",
            "directionalityrtl",
            "indent",
            "|",
            "justifyleft",
            "justifycenter",
            "justifyright",
            "justifyjustify",
            "|",
            "touppercase",
            "tolowercase",
            "|",
            "link",
            "unlink",
            "anchor",
            "|",
            "imagenone",
            "imageleft",
            "imageright",
            "imagecenter",
            "|",
            "pagebreak",
            "|",
            "horizontal",
            "date",
            "time",
            "spechars",
            "|",
            "inserttable",
            "deletetable",
            "insertparagraphbeforetable",
            "insertrow",
            "deleterow",
            "insertcol",
            "deletecol",
            "mergecells",
            "mergeright",
            "mergedown",
            "splittocells",
            "splittorows",
            "splittocols",
            "charts",
            "|",
          ],
        ],
      },
      //定时发送
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 86400000; //禁止选择以前的时间
        },
      },
      percentage: 0,
      maxFileSize: 2048, //上传文件的最大值
      secretTypeIdList: [],
      maxFileLen: "", //上传文件列表长度
      files: [], //上传文件列表
      loadProgress: 0, //上传文件进度
      num: 0, //文件第二次上传初始化
      isCrossDisable: "", //是否跨网
      sendtie: false, //是否编辑
      selectmj: true, //选择密级
      key: 0, //工具数据
      secretTypeIdold: "", //选择密级类型的id
      msg: {
        //邮件信息，整个邮件
        approver: [],
        approverStr: [],
        summaryId: "",
        affairId: "",
        to: "",
        toIds: "",
        cc: "",
        timedTask: false,
        ccIds: "",
        receivers: [],
        receiversStr: [],
        copyReceivers: [],
        secretReceivers: [],
        copyReceiversStr: [],
        subject: "",
        secretlevel: "", //密级状态默认为空
        kuaWang: false,
        kuaWangdis: true,
        isTiming: "",
        timingDate: "",
        content: null,
        attachments: [],
        type: "",
        editMailSend: "",
        mark: "",
        replyParentSummaryid: "",
        replyMemberId: "",
        replyMember: "",
        replyParentAffairid: "",
        parentformSummaryid: "",
        forwardMemberId: "",
        forwardMember: "",
        parentformAffairid: "",
        recipient: "",
        copyfor: "",
        secretReceiversStr: [], //密送人
      },
      serverUrl: "/seeyon/rest/attachment", //上传url
      show: false, //是否显示 废弃
      fileList: [], //文件列表
      dialogVisible: true, //选择密级的弹出框是否隐藏
      header: {
        // token: sessionStorage.token
      }, // 有的图片服务器要求请求头需要有token
      timer: null,
      // 第一次定时器timer
      firstTimer: null,
      // 判断是否退出页面且退出发请求
      isResquest: true,
      // 时间戳
      firstAutosaveTime: "",
      // 跨网选项是否展示
      isKuaWangShow: false,
      // 文件是否上传完成
      ifFileUploaded: false,
      // 收件人选中信息
      saveSubmitIds: [],
      // 抄送人选择信息
      copySaveSubmitIds: [],
      // 密送人选择信息
      secretReceiversSaveSubmitIds: [],
      // 审核人选择信息
      approveSaveSubmitIds: [],
      mailSecret:[],//邮件密级
      fileSecret:[],//文件密级
      // timer: null,
    };
  },
  watch: {
    //邮件内容
    msg: {
      handler(n) {
        // console.log("监听msg改变", n);
        if (!n.receiversStr) {
          //   this.msg.receivers = "";
          //   lyy
          this.msg.receivers = [];
        }
        if (!n.copyReceiversStr) {
          //   this.msg.copyReceivers = "";
          //   lyy
          this.msg.copyReceivers = [];
        }
        if (!n.approverStr) {
          //   lyy
          this.msg.approver = [];
        }
        // 说明跨网选中了，清空定时任务的选中状态
        if (n.kuaWang) {
          this.msg.timedTask = false;
        }
      },
      deep: true,
      immediate: true,
      searchName: "",
      searchValue: "",
      searchList: [], //
    },
    /**
     * 监听选择密级弹框的状态，点击写信打开的时候默认不会自动发送邮件，点击确定选择密级之后再开始自动保存
     * @Date: 2022-06-23 17:17:17
     * @param {*} val 当前状态值
     */
    dialogVisible(val) {
      // if (!val) {
      //   this.firstTimer = setTimeout(() => {
      //     this.pushRealTimeData();
      //   }, 100 * 1000);
      // }
    },
  },
  async created() {
    this.firstAutosaveTime = new Date().getTime();
    // console.log(`this.firstAutosaveTime`, this.firstAutosaveTime);
    //获取邮件数量
    // api.emlianum().then((res) => {
    //   console.log(res);
    //   // this.maxFileSize = res.data.uploadMaxSize;
    // });
    // vm = this;
    this.getIntensiveList()
    //是否邮件列表列
    this.lxryc();
    //写信按钮是否弹出密级弹窗
    // console.log(
    //   `编辑页面this.$store.state.isWriteEamil`,
    //   this.$store.state.isWriteEamil
    // );
    if (this.$store.state.isWriteEamil == false) {
      this.$nextTick(() => {
        setTimeout(() => {
          this.dialogVisible = false;
        }, 500);
      });
    }
    // lyy start
    // 初始化收件人,抄送人，审批人
    await this.focusSearch();
    await this.copyReceiversFocusSearch();
    // await this.approverFocusSearch();
    // lyy end
    //获取邮件详情
    this.getdata();
  },
  async mounted() {
    // console.log('editor.vue-params---', this.$route.params)
    // let {sendTo} = this.$route.params
    // sendTo = sendTo.map(item => item.id.slice(7))
    // let {msg} = await api.getPeopleMsg({ids: [...sendTo].toString()})
    // console.log('res---', msg)
    //
    // msg.forEach((item) => {
    //   this.receiversOptions.push({
    //     ...item,
    //     operationName: `${item.name} (${item.loginName}-${item.department})`,
    //     value: item.name + `(${item.department})`,
    //   });
    //
    //   this.receiversStr.push(item.memberId)
    // });
    //
    // console.log('receiversOption---', this.receiversOptions)

    // this.saves();
    this.isshow = true; //暂缓显示编辑板
    // api.emlianum().then((res) => {
    //   if (res.code == 200) {
    //     this.$store.commit("setnum", res.data);
    //   }
    // });
    // this.secretTypeIdold = this.msg.secretTypeId

    /**
     * 1.文件第一次进入拖动区时，触发 dragenter 事件
     * 2.文件在拖动区来回拖拽时，不断触发 dragover 事件
     * 3.文件已经在拖动区，并松开鼠标时，触发 drop 事件
     * 4.文件在拖动区来回拖拽时，不断触发dragleave 事件
     * auth: tangxiangping
     * date: 2022/06/06 start
     */
    var dropbox = document.getElementById("app");
    dropbox.addEventListener("drop", this.enentDrop, false);
    dropbox.addEventListener("dragleave", this.dragleave, false);
    dropbox.addEventListener("dragenter", this.dragenter, false);
    dropbox.addEventListener("dragover", this.dragover, false);
    /**tangxiangping 2022-06-06 end */

    //是红网需要弹出密级弹出框，否之则隐藏
    // if (this.$store.state.isredNet) {
    //   this.dialogVisible = true;
    // } else {
    //   this.dialogVisible = false;
    // }
    // 用于判断当前用户是否有跨网权限
    // api
    //   .getKuaWangShowApi()
    //   .then((res) => {
    //     if (res.code == "1001") {
    //       // 说明跨网权限
    //       this.isKuaWangShow = true;
    //     } else {
    //       this.isKuaWangShow = false;
    //       this.msg.kuaWang = false;
    //     }
    //   })
    //   .catch((err) => {
    //     this.isKuaWangShow = false;
    //     this.msg.kuaWang = false;
    //   });

  },
  beforeDestroy() {
    // console.log("执行了组件销毁生命周期函数");
    this.isResquest = false;
    let dropbox = document.getElementById("app");
    dropbox.removeEventListener("drop", this.enentDrop, false);
    dropbox.removeEventListener("dragleave", this.dragleave, false);
    dropbox.removeEventListener("dragenter", this.dragenter, false);
    dropbox.removeEventListener("dragover", this.dragover, false);
    if (this.firstTimer) {
      clearTimeout(this.firstTimer);
    }
    clearTimeout(this.timer);
  },
  methods: {
    //获取邮件密级
    getIntensiveList(){
      api.secrets().then(res=>{
        this.mailSecret = JSON.parse(res.data)
        this.fileSecret = JSON.parse(res.data)
        console.log('获取邮件密级',this.mailSecret)
      })
    },
    // 邮件密级更改
    secretTypeChange(val){
      this.fileSecret = this.mailSecret.filter(item=>{
        return val >= item.sort
      })
      this.fileList.forEach(item=>{
        item.secretLevel = ''
      })
      this.msg.secretLevel = val
    },
    /**
     * 选择密级弹框取消点击事件
     * @Date: 2022-06-23 17:19:03
     */
    handleSelectSecretConcel() {
      document.querySelector(".mid").style.display = "flex";
      document.querySelector(".resize").style.display = "flex";
      document.querySelector(".right").style.width = "auto";
      this.$router.back();
    },
    /**
     * 取消自动保存并退出
     * @Date: 2022-06-29 11:30:10
     * @return {*}
     */
    async cancelSave() {
      // console.log('this.firstAutosaveTime', this.firstAutosaveTime)
      // console.log('this.msg.affairId', this.msg)
      this.sendtie = true;
      // const res = await api.cancelAutosaveApi(
      //   this.firstAutosaveTime,
      //   this.msg.affairId
      // );
      this.$store.commit("changeCancelSaveDraftRandom");
      this.getnum();
    },

    /**
     * 监听收件人移除项
     */
    removeReceiverTag() {
      if (Array.isArray(this.saveSubmitIds) && this.saveSubmitIds.length != 0) {
        this.msg.receivers = this.saveSubmitIds.map((item) => item.value);
      }
      if (this.msg.receivers.length == 0) {
        // this.focusSearch();
      }
      //  <!-- 屏蔽邮件审批  -->
      this.emailApproval(false);
    },

    /**
     * 监听抄送人移除项
     */
    removeCopyReceiverTag() {
      //   lyy====================
      if (
        Array.isArray(this.copySaveSubmitIds) &&
        this.copySaveSubmitIds.length != 0
      )
        this.msg.copyReceivers = this.copySaveSubmitIds.map(
          (item) => item.value
        );
      if (this.msg.copyReceivers && this.msg.copyReceivers.length == 0) {
        // this.copyReceiversFocusSearch();
      }
      //  <!-- 屏蔽邮件审批  -->
      this.emailApproval(false);
    },
    /**
     * 监听密送人移除项
     */
    removeSecretReceiversTag() {
      if (
        Array.isArray(this.secretReceiversSaveSubmitIds) &&
        this.secretReceiversSaveSubmitIds.length != 0
      )
        this.msg.secretReceivers = this.secretReceiversSaveSubmitIds.map(
          (item) => item.value
        );
      //  <!-- 屏蔽邮件审批  -->
      this.emailApproval(false);
    },

    /**
     * 监听审批人人移除项
     */
    removeApproveTag() {
      //   lyy
      if (
        Array.isArray(this.approveSaveSubmitIds) &&
        this.approveSaveSubmitIds.length != 0
      )
        this.msg.approver = this.approveSaveSubmitIds.map((item) => item.value);
      if (this.msg.approver && this.msg.approver.length == 0) {
        // this.approverFocusSearch();
      }
    },

    /**
     * 收件人 输入发请求
     */
    focusSearch() {
      this.receiversOptions = [];
      let obj = {
        key: "",
        isS: "2",
        level:this.msg.secretlevel
      };
      // loadingInstance.close();
      api.searchQueryStaff(obj).then((res) => {
        if (res.code == 200) {
          this.searchList = res.data;
          res.data.forEach((item) => {
            this.receiversOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },
    /**
     * lyy
     * 抄送人 输入发请求
     */
    copyReceiversFocusSearch() {
      this.copyReceiversOptions = [];
      let obj = {
        key: "",
        isS: "2",
        level:this.msg.secretlevel
      };
      api.searchQueryStaff(obj).then((res) => {
        if (res.code == 200) {
          // loading.close()
          // console.log("搜索人员", res.data);
          res.data.forEach((item) => {
            this.copyReceiversOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },
    /**
     * lyy
     * 审批人 输入发请求
     */
    approverFocusSearch() {
      this.approverOptions = [];
      let obj = {
        key: "",
        isS: "1",
        level:this.msg.secretlevel
      };
      api.searchQueryStaff(obj).then((res) => {
        if (res.code == 200) {
          // loading.close()
          // console.log("搜索人员", res);
          res.data.forEach((item) => {
            this.searchName = item.name;
            this.searchValue = `Member|${item.memberId}`;
            this.approverOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },

    selectBlur(e) {
      //   console.log(111111111111);
      //this.flag 防抖
      this.receiversOptions = [];
      // console.log(e, "e的值");
      if (e != "") {
        let obj = {
          key: e + "",
          isS: "2",
          level:this.msg.secretlevel
        };
        // if (this.flag) return;
        // this.flag = true;
        if (this.timer) {
          clearTimeout(this.timer);
        }
        if (e) {
          this.timer = setTimeout(() => {
            api.searchQueryStaff(obj).then((res) => {
              // console.log("搜索人员", res);
              if (res.code == 200) {
                this.searchList = res.data;
                res.data.forEach((item) => {
                  this.receiversOptions.push({
                    ...item,
                    operationName: `${item.name} (${item.loginName}-${item.department})`,
                    value: item.name + `(${item.department})`,
                  });
                });
              }
            });
          }, 600);
        } else {
          api.searchQueryStaff(obj).then((res) => {
            // console.log("搜索人员", res);
            if (res.code == 200) {
              this.searchList = res.data;
              res.data.forEach((item) => {
                this.receiversOptions.push({
                  ...item,
                  operationName: `${item.name} (${item.loginName}-${item.department})`,
                  value: item.name + `(${item.department})`,
                });
              });
            }
          });
        }
      } else {
        // lyy
        // this.focusSearch();
      }
    },
    /**
     * 组件选中项触发的change事件
     * @param {Object} val 选中数据的集合
     */
    selectChange(val) {
      if (val.length !== 0 && val.length >= this.msg.receivers.length) {
        // console.log("新增", this.receiversOptions);
        let receiverObj = this.receiversOptions.find(
          (receiverItem) => receiverItem.memberId == val[val.length - 1]
        );
        if (receiverObj) {
          this.saveSubmitIds.push({
            textName: receiverObj.value,
            text: receiverObj.name,
            value: `Member|${receiverObj.memberId}`,
          });
          this.msg.receivers.push(`Member|${receiverObj.memberId}`);
          this.msg.receiversStr.push(receiverObj.value);
        }
        // this.$nextTick(() => {
        //   this.$refs.receiver.blur();
        // });
      } else {
        if (val.length > 0) {
          const newArr = [];
          val.forEach((item) => {
            this.saveSubmitIds.forEach((e) => {
              if (item == e.value.split("|")[1]) {
                newArr.push(e);
              }
            });
          });
          this.saveSubmitIds = [...newArr];
        } else {
          this.msg.receiversStr = [];
          this.msg.receivers = [];
          this.saveSubmitIds = [];
        }
      }
      if (
        Array.isArray(this.saveSubmitIds) &&
        this.saveSubmitIds.length != 0 &&
        this.msg.receiversStr.length > 0
      ) {
        this.msg.receivers = this.saveSubmitIds.map((item) => item.value);
        this.msg.receiversStr = this.saveSubmitIds.map(
          (item) => item.textName || item.text
        );
      }
      if (this.msg.receiversStr.length == 0) {
        this.msg.receivers = [];
        this.msg.receiversStr = [];
      }
    },

    selectClear() {
      this.msg.receiversStr = "";
    },
    /***
     * 抄送人
     * * e 的值为  输入的值
     */
    selectBlurCopyReceiver(e) {
      this.copyReceiversOptions = [];
      if (e != "") {
        let obj = {
          key: e + "",
          isS: "2",
          level:this.msg.secretlevel
        };
        if (this.timer) {
          clearTimeout(this.timer);
        }
        if (e) {
          this.timer = setTimeout(() => {
            //  // 开始加载
            //     let loading = this.$loading({
            //       lock: true,//lock的修改符--默认是false
            //       text: "加载中，请稍候...",//显示在加载图标下方的加载文案
            //       background: "rgba(0,0,0,0.8)",//遮罩层颜色
            //       spinner: "el-icon-loading",//自定义加载图标类名
            //     });
            api.searchQueryStaff(obj).then((res) => {
              if (res.code == 200) {
                // loading.close()
                // console.log("搜索人员", res.data);
                res.data.forEach((item) => {
                  this.copyReceiversOptions.push({
                    ...item,
                    operationName: `${item.name} (${item.loginName}-${item.department})`,
                    value: item.name + `(${item.department})`,
                  });
                });
              }
            });
          }, 600);
        } else {
          api.searchQueryStaff(obj).then((res) => {
            if (res.code == 200) {
              // console.log("搜索人员", res.data);
              res.data.forEach((item) => {
                this.copyReceiversOptions.push({
                  ...item,
                  operationName: `${item.name} (${item.loginName}-${item.department})`,
                  value: item.name + `(${item.department})`,
                });
                this.flag = true;
              });
            }
          });
        }
      } else {
        //   lyy
        // this.copyReceiversFocusSearch();
      }
    },
    /***
     * 密送人
     * * e 的值为  输入的值
     */
    selectBlurSecretReceivers(e) {
      this.secretReceiversOptions = [];
      if (e != "") {
        let obj = {
          key: e + "",
          isS: "2",
          level:this.msg.secretlevel
        };
        if (this.timer) {
          clearTimeout(this.timer);
        }
        if (e) {
          this.timer = setTimeout(() => {
            //  // 开始加载
            //     let loading = this.$loading({
            //       lock: true,//lock的修改符--默认是false
            //       text: "加载中，请稍候...",//显示在加载图标下方的加载文案
            //       background: "rgba(0,0,0,0.8)",//遮罩层颜色
            //       spinner: "el-icon-loading",//自定义加载图标类名
            //     });
            api.searchQueryStaff(obj).then((res) => {
              if (res.code == 200) {
                // loading.close()
                // console.log("搜索人员", res.data);
                res.data.forEach((item) => {
                  this.secretReceiversOptions.push({
                    ...item,
                    operationName: `${item.name} (${item.loginName}-${item.department})`,
                    value: item.name + `(${item.department})`,
                  });
                });
              }
            });
          }, 600);
        } else {
          api.searchQueryStaff(obj).then((res) => {
            if (res.code == 200) {
              // console.log("搜索人员", res.data);
              res.data.forEach((item) => {
                this.secretReceiversOptions.push({
                  ...item,
                  operationName: `${item.name} (${item.loginName}-${item.department})`,
                  value: item.name + `(${item.department})`,
                });
                this.flag = true;
              });
            }
          });
        }
      } else {
        //   lyy
        // this.copyReceiversFocusSearch();
      }
    },

    selectChangeCopyReceiver(val) {
      //   console.log("修改内容", val);
      if (val.length !== 0 && val.length >= this.msg.copyReceivers.length) {
        let receiverObj = this.copyReceiversOptions.find(
          (receiverItem) => receiverItem.memberId == val[val.length - 1]
        );
        if (receiverObj) {
          this.copySaveSubmitIds.push({
            textName: receiverObj.value,
            text: receiverObj.name,
            value: `Member|${receiverObj.memberId}`,
          });
          this.msg.copyReceivers.push(`Member|${receiverObj.memberId}`);
          this.msg.copyReceiversStr.push(receiverObj.value);
        }
        // this.$nextTick(() => {
        //   this.$refs.copyReceiver.blur();
        // });
      } else {
        // console.log(this.copySaveSubmitIds);
        if (val.length > 0) {
          const newArr = [];
          val.forEach((item) => {
            this.copySaveSubmitIds.forEach((e) => {
              if (item == e.value.split("|")[1]) {
                newArr.push(e);
              }
            });
          });
          this.copySaveSubmitIds = [...newArr];
        } else {
          this.copySaveSubmitIds = [];
          this.msg.copyReceivers = [];
          this.msg.copyReceiversStr = [];
        }
      }

      //   // lyy
      if (
        Array.isArray(this.copySaveSubmitIds) &&
        this.copySaveSubmitIds.length != 0 &&
        this.msg.copyReceiversStr.length > 0
      ) {
        this.msg.copyReceivers = this.copySaveSubmitIds.map(
          (item) => item.value
        );
        this.msg.copyReceiversStr = this.copySaveSubmitIds.map(
          (item) => item.textName || item.text
        );
      }
      if (this.msg.copyReceiversStr.length == 0) {
        this.msg.copyReceivers = [];
        this.msg.copyReceiversStr = [];
      }

      //   console.log("this.copySaveSubmitIds", this.copySaveSubmitIds);
      //   console.log(
      //     "this.copyReceivers",
      //     this.msg.copyReceivers,
      //     this.msg.copyReceiversStr
      //   );
    },
    selectChangeSecretReceivers(val) {
      //   console.log("修改内容", val);
      if (val.length !== 0 && val.length >= this.msg.secretReceivers.length) {
        let receiverObj = this.secretReceiversOptions.find(
          (receiverItem) => receiverItem.memberId == val[val.length - 1]
        );
        if (receiverObj) {
          this.secretReceiversSaveSubmitIds.push({
            textName: receiverObj.value,
            text: receiverObj.name,
            value: `Member|${receiverObj.memberId}`,
          });
          this.msg.secretReceivers.push(`Member|${receiverObj.memberId}`);
          this.msg.secretReceiversStr.push(receiverObj.value);
        }
        // this.$nextTick(() => {
        //   this.$refs.copyReceiver.blur();
        // });
      } else {
        // console.log(this.copySaveSubmitIds);
        if (val.length > 0) {
          const newArr = [];
          val.forEach((item) => {
            this.secretReceiversSaveSubmitIds.forEach((e) => {
              if (item == e.value.split("|")[1]) {
                newArr.push(e);
              }
            });
          });
          this.secretReceiversSaveSubmitIds = [...newArr];
        } else {
          this.secretReceiversSaveSubmitIds = [];
          this.msg.secretReceivers = [];
          this.msg.secretReceiversStr = [];
        }
      }

      //   // lyy
      if (
        Array.isArray(this.secretReceiversSaveSubmitIds) &&
        this.secretReceiversSaveSubmitIds.length != 0 &&
        this.msg.secretReceiversStr.length > 0
      ) {
        this.msg.secretReceivers = this.secretReceiversSaveSubmitIds.map(
          (item) => item.value
        );
        this.msg.secretReceiversStr = this.secretReceiversSaveSubmitIds.map(
          (item) => item.textName || item.text
        );
      }
      if (this.msg.secretReceiversStr.length == 0) {
        this.msg.secretReceivers = [];
        this.msg.secretReceiversStr = [];
      }

      //   console.log("this.copySaveSubmitIds", this.copySaveSubmitIds);
      //   console.log(
      //     "this.copyReceivers",
      //     this.msg.copyReceivers,
      //     this.msg.copyReceiversStr
      //   );
    },

    selectClearCopyReceiver() {
      this.msg.copyReceiversStr = "";
    },
    /***
     * 审批人
     * * e 的值为  输入的值
     */
    selectBlurApprover(e) {
      this.approverOptions = [];
      //   console.log("发请求");
      if (e != "") {
        let obj = {
          key: e + "",
          isS: "1",
          level:this.msg.secretlevel
        };
        if (this.timer) {
          clearTimeout(this.timer);
        }
        if (e) {
          this.timer = setTimeout(() => {
            //  // 开始加载
            //   let loading = this.$loading({
            //     lock: true,//lock的修改符--默认是false
            //     text: "加载中，请稍候...",//显示在加载图标下方的加载文案
            //     background: "rgba(0,0,0,0.8)",//遮罩层颜色
            //     spinner: "el-icon-loading",//自定义加载图标类名
            //   });
            api.searchQueryStaff(obj).then((res) => {
              if (res.code == 200) {
                // loading.close()
                // console.log("搜索人员", res);
                res.data.forEach((item) => {
                  this.searchName = item.name;
                  this.searchValue = `Member|${item.memberId}`;
                  this.approverOptions.push({
                    ...item,
                    operationName: `${item.name} (${item.loginName}-${item.department})`,
                    value: item.name + `(${item.department})`,
                  });
                });
              }
            });
          }, 600);
        } else {
          api.searchQueryStaff(obj).then((res) => {
            if (res.code == 200) {
              //   console.log("搜索人员", res);
              res.data.forEach((item) => {
                this.searchName = item.name;
                this.searchValue = `Member|${item.memberId}`;
                this.approverOptions.push({
                  ...item,
                  operationName: `${item.name} (${item.loginName}-${item.department})`,
                  value: item.name + `(${item.department})`,
                });
              });
            }
          });
        }
      } else {
        //   lyy
        // this.approverFocusSearch();
      }
    },

    selectChangeApprover(val) {
      //   console.log("修改内容", val);
      //  新增
      if (val.length !== 0 && val.length >= this.msg.approver.length) {
        let receiverObj = this.approverOptions.find(
          (receiverItem) => receiverItem.memberId == val[val.length - 1]
        );
        if (receiverObj) {
          this.approveSaveSubmitIds.push({
            textName: receiverObj.value,
            text: receiverObj.name,
            value: `Member|${receiverObj.memberId}`,
          });
          // this.msg.approver.push(`Member|${receiverObj.memberId}`);
          // this.msg.approverStr.push(receiverObj.value);
        }
        // this.$nextTick(() => {
        //   this.$refs.approver.blur();
        // });
      } else {
        if (val.length > 0) {
          const newArr = [];
          val.forEach((item) => {
            this.approveSaveSubmitIds.forEach((e) => {
              if (item == e.value.split("|")[1]) {
                newArr.push(e);
              }
            });
          });
          this.approveSaveSubmitIds = [...newArr];
        } else {
          // this.msg.approver = [];
          // this.msg.approverStr = [];
          this.approveSaveSubmitIds = [];
        }
      }
      if (
        Array.isArray(this.approveSaveSubmitIds) &&
        this.approveSaveSubmitIds.length != 0 &&
        this.msg.approverStr.length > 0
      ) {
        this.msg.approver = this.approveSaveSubmitIds.map((item) => item.value);
        this.msg.approverStr = this.approveSaveSubmitIds.map(
          (item) => item.textName || item.text
        );
      }
      if (this.msg.approverStr.length == 0) {
        this.msg.approver = [];
        this.msg.approverStr = [];
      }

      //   console.log("this.approve/r", this.msg.approver, this.msg.approverStr);
    },

    selectClearApprover() {
      this.msg.approverStr = [];
    },

    //弹出框选择密级类型点击确定
    selectSecretType() {
      if (!this.msg.secretTypeId) {
        // console.log("请选择密级！");
        this.$alert("请选择密级!", "提示", {
          confirmButtonText: "确定",
          type: "warning",
        })
          .then(() => {})
          .catch((_) => {});
      } else {
        this.dialogVisible = false;
      }
    },

    /**
     * @function void:pushRealTimeData 通过axios轮询像后端发送请求去保存邮件的临时信息
     */
    pushRealTimeData() {
      let self = this;
      self.msg.type = "draft";
      let arr = [];
      self.fileList.forEach((d) => {
        arr.push(d.fileUrl);
      });
      self.msg.attachments = arr.toString();
      self.msg.autosave = "1";
      self.msg.firstAutosaveTime = self.firstAutosaveTime;

      let sendData = {
        ...this.msg,
        copyReceiversStr: this.msg.copyReceiversStr.toString(),
        receiversStr: this.msg.receiversStr.toString(),
        // approverStr: this.msg.approverStr.toString(),
        // approver: this.msg.approver.toString(),
        receivers: this.msg.receivers.toString(),
        copyReceivers: this.msg.copyReceivers.toString(),
      };
      api.sendemail(sendData).then((res) => {
        if (self.timer) {
          clearTimeout(self.timer);
        }
        self.timer = setTimeout(() => {
          if (self.isResquest) {
            self.pushRealTimeData();
          } else {
            return;
          }
        }, 100 * 1000);
      });
    },
    //密级类型的change事件 ,重新切换密级类型，保存原先的选中密级
    cct(n) {
      if (n) {
        this.secretTypeIdold = this.msg.secretTypeId;
      }
    },
    //下载文件
    downflie(file) {
      console.log('下载文件',file);
      window.location.href = encodeURI(
        `/seeyon/rest/attachment/file/${encodeURI(file.fileUrl)}?createDate=${
          file.createdate
        }&fileName=${file.filename}`
      );
    },
    //校验邮件内容是否必填
    jycs() {
      // if (
      //   this.msg.subject == "" ||
      //   this.msg.receiversStr == "" ||
      //   this.msg.subject == null ||
      //   this.msg.receiversStr == null
      // ) {
      //   this.$message.warning("请填入必要信息");
      //   return false;
      // } else if (
      //   this.msg.timedTask == true &&
      //   (this.msg.timingDate == undefined || this.msg.timingDate == "")
      // ) {
      //   this.$message.warning("请填入定时信息");
      //   return false;
      // } else if (
      //   ((this.msg.kuaWangdis && this.$store.state.isredNet) ||
      //     this.msg.kuaWang) &&
      //   !this.msg.approverStr
      // ) {
      //   this.$message.warning("请选择审批人");
      //   return false;
      // } else {
      //   console.log(this.msg.timedTask == true && this.msg.timingDate == "");
      //   return true;
      // }
      if (
        this.msg.subject == "" ||
        this.msg.receiversStr == "" ||
        this.msg.subject == null ||
        this.msg.receiversStr == null
      ) {
        this.$message.warning("请填入必要信息");
        return false;
      } else if (
        this.msg.timedTask == true &&
        (this.msg.timingDate == undefined || this.msg.timingDate == "")
      ) {
        this.$message.warning("请填入定时信息");
        return false;
      }
      else if (this.msg.subject.length > 50){
        this.$message.warning("邮件主题不能超过50个字符");
        return false;
      }
      else if(this.msg.secretlevel == ''){
        this.$message.warning("请选择邮件密级");
        return false;
      }
      else if (this.fileList.filter((d) => {
         return !d.secretLevel
        }).length > 0) {
           this.$message.warning("请选择文件密级");
           return false;
        }
      // else if (
      //   ((this.msg.kuaWangdis && this.$store.state.isredNet) ||
      //     this.msg.kuaWang) &&
      //   this.msg.approver.length == 0
      // ) {
      //   this.$message.warning("请选择审批人");
      //   return false;
      // }
      else {
        // console.log(this.msg.timedTask == true && this.msg.timingDate == "");
        return true;
      }
    },
    //刷新事件
    refnav() {
      this.$emit("refleftnav");
    },
    //删除文件
    delflie(index) {
      this.fileList.splice(index, 1);
    },
    //上传文件
    async uploadFile(file) {
      this.ifFileUploaded = false;
      let break_on = true;
      this.maxFileLen = 0;
      this.num++;
      if (this.num == this.files.length) {
        // console.log("文件上传",this.files);
        this.num = 0;
        let from = new FormData();
        this.files.forEach((d) => {
          let size = (d.raw.size / 1024 / 1024).toFixed(2);
          if (size >= this.maxFileSize) {
            break_on = false;
          } else {
            from.append("file", d.raw);
          }
        });
        from.append("useMyPathAppType", "mail");
        if (break_on) {
          this.loading = true;
          // const onUploadProgress = (progressEvent) => {
          //   let percent =
          //     ((progressEvent.loaded / progressEvent.total) * 100) | 0;
          //   this.percentage = `上传进度：${percent}%`;
          // };
          let res = await
            api.loadflie
            (
                  from,
                  (progressEvent) => {
                    let percent =
                    ((progressEvent.loaded / progressEvent.total) * 100) | 0;
                    this.percentage = `上传进度：${percent}%`;
                  }
            )
            // .then((res) => {
            //   //   console.log(res);
            //   // lyy  没有主题就将文件名替换为主题
            //   if (!this.msg.subject) {
            //     this.msg.subject = res.atts[0].filename.split(".")[0];
            //   }
            //   this.$refs.upload.clearFiles();
            //   this.files = [];
            //   if (res.code == "1") {
            //     this.$message.error(res.message);
            //     this.loading = false;
            //     // return;
            //   }
            //   else {
            //     res.atts.forEach((i) => {
            //       i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
            //       this.fileList.push(i);
            //     });
            //     this.loading = false;
            //     this.ifFileUploaded = true;
            //   }
            // })
            // .catch((err) => {
            //   // 当上传文件出错时，将进度清空，进度条隐藏，给出提示
            //   this.$message.error("上传超时");
            //   this.percentage = 0;
            //   this.loading = false;
            // });

          // console.log(res)
          if (res.code && res.code == 1) {
            this.$message.error(res.message);
            this.percentage = 0;
            this.loading = false;
            this.$refs.upload.clearFiles();
          }
          else if (res && res.atts) {
              // lyy  没有主题就将文件名替换为主题
              if (!this.msg.subject) {
                this.msg.subject = res.atts[0].filename.split(".")[0];
              }
              this.$refs.upload.clearFiles();
              this.files = [];

              res.atts.forEach((i) => {
                    i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
                    this.fileList.push(i);
              });
              this.loading = false;
              this.ifFileUploaded = true;
          }
          else {
              this.$message.error("上传超时");
              this.percentage = 0;
              this.loading = false;
          }
        } else {
          this.$message.error("上传附件大小不能超过2G");
        }
      }
    },
    //切换密级类型的change事件
    MailFileSecretVerify() {
      this.msg.kuaWangdis = true;
      this.msg.kuaWang = false;
      //切换密级信息不需要弹出提示信息供用户感知  20210908 10:28 modify yangyanhua  Demander:dengyawen
      // this.$confirm('密级变更后需要重新编辑当前邮件，您确定要改变密级吗?', '提示', {
      //   confirmButtonText: '确定',
      //   cancelButtonText: '取消',
      //   showClose:false,
      //   type: 'warning'
      // }).then(() => {
      //重新选择密级，不清空收件人，选了不符合密级状态的人员，再点击发送时需要给出提示信息，让客户自己清空不符合要求的人员信息
      // this.msg.receiversStr = ""
      // this.msg.copyReceiversStr = ""//不清空抄送
      //外层，跨网是否需要禁用
      api
        .MailFileSecretVerify({ secret: this.msg.secretTypeId })
        .then((res) => {
          //   console.log(res);
          if (res.code != 10001) {
            this.$nextTick().then(() => {
              this.msg.secretTypeId = this.secretTypeIdold;
              this.msg.kuaWangdis = true; //是否跨网禁用
              this.$forceUpdate();
            });
            this.$message.error(res.msg);

            api
              .MailFileSecretVerify({ secret: this.msg.secretTypeId })
              .then((res) => {
                // this.fileList = []
                let obj = {
                  secretTypeId: this.msg.secretTypeId,
                  fileNames: [],
                };
                this.fileList.forEach((d) => {
                  obj.fileNames.push(d.filename);
                });
                obj.fileNames = obj.fileNames.toString();

                api.isSecret(obj).then((res) => {
                  this.$nextTick().then(() => {
                    this.msg.kuaWangdis = res.msg.isSecret;
                    this.$forceUpdate();
                  });

                  if (res.code == 10001) {
                    if (res.msg.checkFileIsClear == true) {
                      this.$confirm(
                        "文件列表中文件密级超出, 是否清空文件列表?",
                        "提示",
                        {
                          confirmButtonText: "确定",
                          cancelButtonText: "取消",
                          showClose: false,
                          type: "warning",
                        }
                      )
                        .then(() => {
                          this.$nextTick().then(() => {
                            this.fileList = [];
                            this.secretTypeIdold = this.msg.secretTypeId;
                            this.msg.kuaWangdis = res.msg.isSecret;
                          });
                        })
                        .catch(() => {
                          this.$nextTick().then(() => {
                            this.msg.secretTypeId = this.secretTypeIdold;
                            // console.log(this.secretTypeIdold);
                            this.$forceUpdate();
                          });
                        });
                    }
                    if (res.msg.isSecret == true) {
                      // this.$message.warning("涉密邮件不可跨网")
                      this.msg.kuaWang = false;
                      this.msg.kuaWangdis = true;
                      // this.secretTypeIdold = this.msg.secretTypeId
                    }
                  } else {
                    this.$message.warn(res.msg);
                  }

                  this.key += 1;
                });
              });
          } else {
            // this.fileList = []
            let obj = {
              secretTypeId: this.msg.secretTypeId,
              fileNames: [],
            };
            this.fileList.forEach((d) => {
              obj.fileNames.push(d.filename);
            });
            obj.fileNames = obj.fileNames.toString();

            api.isSecret(obj).then((res) => {
              this.$nextTick().then(() => {
                this.msg.kuaWangdis = res.msg.isSecret;
                // console.log(
                //   "---------------------------------------------------"
                // );
                // console.log(this.msg.kuaWangdis);
                this.$forceUpdate();
              });

              if (res.code == 10001) {
                if (res.msg.checkFileIsClear == true) {
                  this.$confirm(
                    "文件列表中文件密级超出, 是否清空文件列表?",
                    "提示",
                    {
                      confirmButtonText: "确定",
                      cancelButtonText: "取消",
                      showClose: false,
                      type: "warning",
                    }
                  )
                    .then(() => {
                      this.$nextTick().then(() => {
                        this.fileList = [];
                        this.secretTypeIdold = this.msg.secretTypeId;
                        this.msg.kuaWangdis = res.msg.isSecret;
                      });
                    })
                    .catch(() => {
                      this.$nextTick().then(() => {
                        this.msg.secretTypeId = this.secretTypeIdold;
                        // console.log(this.secretTypeIdold);
                        this.$forceUpdate();
                      });
                    });
                }
                if (res.msg.isSecret == true) {
                  // this.$message.warning("涉密邮件不可跨网")
                  this.msg.kuaWang = false;
                  this.msg.kuaWangdis = true;
                  // this.secretTypeIdold = this.msg.secretTypeId
                }
              } else {
                this.$message.warn(res.msg);
              }

              this.key += 1;
            });
            // if (this.msg.secretTypeId == -637209554414910365){
            //     this.$message.warning("涉密邮件不可跨网")
            //     this.msg.kuaWang = false
            // }
          }
        });

      this.$forceUpdate();
      // }).catch(() => {
      //   this.msg.secretTypeId = this.secretTypeIdold

      // });
      //   console.log(this.msg.secretTypeId);
    },
    // 上传进度
    uploadVideoProcess(event, file, fileList) {
      this.loadProgress = parseInt(event.percent); // 动态获取文件上传进度
      if (this.loadProgress >= 100) {
        this.loadProgress = 100;
        // setTimeout( () => {this.progressFlag = false}, 1000) // 一秒后关闭进度条
      }
    },

    beforeFeedBackExports(file, fileList, isDragUpload) {
      let obj = {
        fileNames: [],
        fslId: this.msg.secretTypeId,
      };
      fileList.forEach((d) => {
        obj.fileNames.push(d.name);
      });
      obj.fileNames = obj.fileNames.toString();
      let currLength = fileList.length;
      this.maxFileLen = Math.max(currLength, this.maxFileLen);
      // this.files = fileList
      setTimeout(() => {
        if (currLength == this.maxFileLen) {
          this.files = fileList;
          // if (this.$store.state.isredNet) {
          //   console.log(fileList);
          //   api.MailFileSecret(obj).then((res) => {
          //     if (res.code == 200) {
          //       this.$message.success("文件密级校验成功");
          //       // 兼容匹配拖拽上传
          //       if (isDragUpload === "dragUpload") {
          //         if (this.files.length > 0 && this.num === 0) {
          //           this.num = this.files.length - 1;
          //         }
          //         this.uploadFile();
          //       }
          //       this.$refs.upload.submit();
          //     }
          //     else {
          //       if (res.msg == "附件密级不能大于文件密级！") {
          //         this.$message.error("附件密级不能大于邮件密级！");
          //       }
          //       else {
          //         this.$message.error(res.msg);
          //       }
          //       this.maxFileLen = 0;
          //     }
          //     this.$refs.upload.clearFiles();
          //   });
          // }
          // else {
          //   // 兼容匹配拖拽上传
          //   if ((isDragUpload = "dragUpload")) {
          //     if (this.files.length > 0 && this.num === 0) {
          //       this.num = this.files.length - 1;
          //     }
          //     this.uploadFile();
          //   }
          //   this.$refs.upload.submit();
          // }

          if (isDragUpload === "dragUpload") {
            if (this.files.length > 0 && this.num === 0) {
              this.num = this.files.length - 1;
            }
            this.uploadFile();
          }
          this.$refs.upload.submit();
          this.$refs.upload.clearFiles();
        }
      });
    },

    // 校验
    jy() {
      let obj = {
        fileNames: [],
        fslId: this.msg.secretTypeId,
      };
      this.files.forEach((d) => {
        obj.fileNames.push(d.name);
      });
      obj.fileNames = obj.fileNames.toString();
      api.MailFileSecret(obj).then((res) => {
        // console.log(res);
        if (res.code == 200) {
          this.$message.success("文件密级校验成功");
          // this.$refs.upload.submit();
        } else {
          this.$message.error(res.msg);
          this.$refs.upload.handleRemove(file);
          this.$refs.upload.handleRemove(file);
        }
      });
    },

    beforeFeedBackExport(file, fileList) {
      let obj = {
        fileNames: file.name,
        fslId: this.msg.secretTypeId,
      };
      // fileList.forEach( d =>{
      //     obj.fileNames.push(d.name)
      // })
      // obj.fileNames =  obj.fileNames.toString()
      //
      // let currLength = fileList.length
      // this.maxFileLen = Math.max(currLength,this.maxFileLen)
      //

      api.MailFileSecret(obj).then((res) => {
        // console.log(res);
        if (res.code == 200) {
          this.$message.success("文件密级校验成功");
          this.$refs.upload.submit();
        } else {
          this.$message.error(res.msg);
          this.$refs.upload.handleRemove(file);
        }
      });
      // setTimeout(() =>{
      //     if (currLength != this.maxFileLen) return
      //     api.MailFileSecret(obj).then(res => {
      //         console.log(res)
      //         if (res.code == 200) {
      //             this.$message.success('文件密级校验成功');
      //             this.$refs.upload.submit();
      //         } else {
      //             this.$message.error(res.msg);
      //             this.$refs.upload.handleRemove(file);
      //
      //         }
      //     })
      // })

      // fileList.forEach( d =>{
      //     obj.fileNames.push(d.name)
      // })
      // let currLength = fileList.length

      // obj.fileNames = obj.fileNames.toString()
      // this.maxFileLen = Math.max (currLength,this.maxFileLen)
      // setTimeout(() =>{
      //     if(currLength == this.maxFileLen) {
      //     api.MailFileSecret(obj).then(res =>{
      //         console.log(res)
      //         if  (res.code == 200){
      //             this.$refs.upload.submit();
      //         }else {
      //             this.$message.error(res.msg);
      //             this.$refs.upload.abort();
      //
      //         }
      //     })
      //     }
      // },0)

      // const isLt2M = (file.size / 1024 / 1024 < 10);
      // if (!extension) {
      //     this.$message({
      //         message: '上传文件只能是xls/xlsx!',
      //         type: 'warning'
      //     });
      //     this.fileUploadList = []
      //     return false;
      // }
      // if (!isLt2M) {
      //     this.$message({
      //         message: "文件大小不可以超过10M",
      //         type: 'warning'
      //     });
      //     this.fileUploadList = []
      //     return false;
      // }
      // return (extension) && isLt2M
    },

    async save() {
      if (!this.jycs()) {
        return false;
      }
      //在点击保存草稿 ，需要将标志重新恢复初值
      if (this.$store.state.isWriteEamil) {
        this.$store.commit("setWriteEamil", false);
      }
      this.msg.type = "draft";
      let arr = [];
      if (this.percentage != 0 && !this.ifFileUploaded) {
        return this.$message.warning("文件还在上传中...");
      }
      var attachmentslevel = {}; //附件等级
      this.fileList.forEach((d) => {
        arr.push(d.fileUrl);
        attachmentslevel[d.fileUrl] = d.secretLevel;
        console.log(d);
      });
      //   console.log("arr :>> ", arr);
      this.msg.attachments = arr.toString();

      //   console.log(this.msg);
      this.msg.timedTask = false;
      this.msg.autosave = "0";
      // 将收件人，抄送人，审批人转为字符串
      let sendData = {
        ...this.msg,
        copyReceiversStr: this.msg.copyReceiversStr.toString(),
        receiversStr: this.msg.receiversStr.toString(),
        // approverStr: this.msg.approverStr.toString(),
        // approver: this.msg.approver.toString(),
        receivers: this.msg.receivers.toString(),
        copyReceivers: this.msg.copyReceivers.toString(),
        secretlevel:this.msg.secretlevel.toString(),
        secretReceivers: this.msg.secretReceivers.toString(),
        secretReceiversStr: this.msg.secretReceiversStr.toString(),
        attachmentslevel:JSON.stringify(attachmentslevel),
      };
      await api.sendemail(sendData).then((res) => {
        // console.log("执行了保存草稿1");
        if (res.code == "10001") {
          this.sendtie = true;
          this.$message.success(res.msg);
        } else {
          this.$message.warning(res.msg);
        }
      });
      this.getnum();
    },

    async saves() {
      this.msg.type = "draft";
      let arr = [];
      if (this.percentage != 0 && !this.ifFileUploaded) {
        return this.$message.warning("文件还在上传中...");
      }
      var attachmentslevel = {}; //附件等级
      this.fileList.forEach((d) => {
        arr.push(d.fileUrl);
        attachmentslevel[d.fileUrl] = d.secretLevel;
        console.log(d);
      });
      this.msg.attachments = arr.toString();
      this.msg.autosave = "0";
      this.msg.timedTask = false;
      let sendData = {
        ...this.msg,
        copyReceiversStr: this.msg.copyReceiversStr.toString(),
        receiversStr: this.msg.receiversStr.toString(),
        // approverStr: this.msg.approverStr.toString(),
        // approver: this.msg.approver.toString(),
        receivers: this.msg.receivers.toString(),
        copyReceivers: this.msg.copyReceivers.toString(),
        secretlevel:this.msg.secretlevel.toString(),
        secretReceivers: this.msg.secretReceivers.toString(),
        secretReceiversStr: this.msg.secretReceiversStr.toString(),
        attachmentslevel:JSON.stringify(attachmentslevel),
      };
      await api.sendemail(sendData).then((res) => {
        // console.log("执行了保存草稿s");
        if (res.code == "10001") {
          this.sendtie = true;
          this.$message.success(res.msg);
          // api.emlianum().then((res) => {
          //   // console.log(res);
          //   if (res.code == 200) {
          //     this.num = res.data;
          //     this.$store.commit("setnum", res.data);
          //     this.$store.commit("changeCancelSaveDraftRandom");
          //   } else {
          //     // console.log('手动存为草稿失败',res.message)
          //     this.$message.error(res.message);
          //   }
          // });
          // this.getnum()
        } else {
          // console.log('自动存为草稿失败',res)
          this.$message.warning(res.msg);
        }
      });
      // this.getnum()
    },
    // 调用父元素传递的自定义方法--refleftnav
    getnum() {
      this.$emit("refleftnav");
    },

    uploadfile() {
      // this.$refs['upload'].$el.click()
      document.querySelector(".flieupload .avatar-uploader input").click();
      this.percentage = 0;
    },

    /** 拖拽功能的监听事件 tangxiangping 2022-06-06 start */
    dragenter(e) {
      this.preventDefault(e);
    },
    dragleave(e) {
      this.preventDefault(e);
    },
    dragover(e) {
      this.preventDefault(e);
    },
    enentDrop(e) {
      this.preventDefault(e);
      let fileData = e.dataTransfer.files;
      if (this.percentage != 0 && !this.ifFileUploaded) {
        return this.$message.warning("文件还在上传中...");
      }
      // 填充附件数据
      this.files = [
        ...this.files,
        ...Array.from(fileData).map((item) => {
          return {
            name: item.name,
            size: item.size,
            type: item.type,
            status: "ready",
            uid: item.lastModified,
            raw: item,
            percentage: 0,
          };
        }),
      ];
      // 判断如果文件类型为空并且文件
      const result = this.files.some((item) => {
        if (item.type == "" && item.size === 0) {
          this.$message.error(`文件夹${item.name}类型不支持`);
        }
        return item.raw
          ? item.raw.type === "" && item.raw.size === 0
          : item.type === "" && item.size === 0;
      });
      if (result) return (this.files = []);

      // 调用文件上传校验方法
      this.beforeFeedBackExports(
        fileData,
        Array.from(fileData).map((item) => {
          return {
            name: item.name,
            size: item.size,
            type: item.type,
            status: "ready",
            uid: item.lastModified,
            raw: item,
            percentage: 0,
          };
        }),
        "dragUpload" // 表示拖拽上传
      );
    },
    preventDefault(e) {
      e.stopPropagation();
      e.preventDefault(); //必填字段
    },
    /** 拖拽功能的监听事件 tangxiangping 2022-06-06 end */

    // 发送邮件
    async send() {
      //在点击发送邮件 ，需要将标志重新恢复初值
      if (this.$store.state.isWriteEamil) {
        this.$store.commit("setWriteEamil", false);
      }
      if (!this.jycs()) {
        return false;
      }

      // 是否需要选择 审批人
      if (!this.msg.kuaWangdis) {
        // 邮件发送前置审批
        //  <!-- 屏蔽邮件审批  -->
        // const checked = await this.emailApproval();
        // if (!checked) return;
      }

      this.msg.type = "send";
      let arr = [];
      //   console.log("editor 1146line", this.percentage, this.ifFileUploaded);
      if (this.percentage != 0 && !this.ifFileUploaded) {
        return this.$message.warning("文件还在上传中...");
      }
      if (this.sendFlag) {
        var attachmentslevel = {}; //附件等级
        this.fileList.forEach((d) => {
          arr.push(d.fileUrl);
          attachmentslevel[d.fileUrl] = d.secretLevel;
          console.log(d);
        });
        this.msg.attachments = arr.toString();
        let obj = this.$route.query.obj;
        // 将收件人，抄送人，审批人转为字符串
        const params = {
          ...this.msg,
          secretlevel:this.msg.secretlevel.toString(),
          copyReceiversStr: this.msg.copyReceiversStr.toString(),
          receiversStr: this.msg.receiversStr.toString(),
          // approverStr: this.msg.approverStr.toString(),
          // approver: this.msg.approver.toString(),
          receivers: this.msg.receivers.toString(),
          copyReceivers: this.msg.copyReceivers.toString(),
          secretReceivers: this.msg.secretReceivers.toString(),
          secretReceiversStr: this.msg.secretReceiversStr.toString(),
          attachmentslevel:JSON.stringify(attachmentslevel),
        };
        console.log(
          "123object :>> ",
          params.copyReceiversStr,
          params.receiversStr,
          // params.approverStr
        );
        // console.log("发送邮件参数", params);
        this.msg.autosave = "0";
        api.sendemail(params).then((res) => {
          // console.log("执行了发送邮件", res);
          if (res.code == 10001) {
            this.$message.success(res.msg);
            this.sendtie = true;
            this.$emit("refleftnav");
          } else {
            // console.log('res.msg2008 :>> ', res.msg);
            this.$message.warning(res.msg);
          }
          this.sendFlag = true;
        });
        this.sendFlag = false;
      }
    },

    /**
     * 邮件审批
     * @desc: 邮件发送前, 需对 收件人、抄送人 进行人员校验
     * @param {boolean} showTip: 是否展示错误提示
     * @return {boolean} 是否允许发送邮件
     */
    async emailApproval(showTip = true) {
      // 收件人、抄送人、密级
      const {
        receivers = [],
        copyReceivers = [],
        secretTypeId,
      } = this.msg || {};
      if (!secretTypeId || secretTypeId == "") return false;

      const loading = this.$loading({
        text: "邮件审批中",
      });

      const result = await api
        .emailApproval({ receivers, copyReceivers, secretTypeId })
        .then((res) => {
          if (res?.code != 10002) {
            if (showTip) this.$message.error(res?.message || "审批失败");
            this.msg.kuaWangdis = true;
            return false;
          }

          this.msg.kuaWangdis = false;
          return true;
        })
        .catch(() => {
          if (showTip) this.$message.error("审批失败");
          this.msg.kuaWangdis = true;
          return false;
        })
        .finally(() => {
          loading.close();
        });

      return result;
    },

    sends() {
      if (!this.jycs()) {
        return false;
      }
      this.msg.type = "send";
      let arr = [];
      if (this.percentage != 0 && !this.ifFileUploaded) {
        return this.$message.warning("文件还在上传中...");
      }
      this.fileList.forEach((d) => {
        arr.push(d.fileUrl);
      });

      let obj = this.$route.query.obj;

      this.msg.attachments = arr.toString();
      this.msg.autosave = "0";
      //   console.log(this.msg);

      api.sendemail(this.msg).then((res) => {
        // console.log("执行了发送邮件2");
        // console.log(res);
        if (res.code == 10001) {
          this.$message.success(res.msg);
          this.$emit("refleftnav");
        } else {
          // console.log('res.msg2040 :>> ', res.msg);
          this.$message.warning(res.msg);
        }
      });
    },
    uploadflieError() {
      // loading动画消失
      this.$message.error("文件上传失败");
    },

    beforeflieUpload() {},

    uploadflieSuccess(res, file) {
      // res为图片服务器返回的数据
      // 获取富文本组件实例
      // console.log(res)
      // if (res.atts.length != 0) {
      //     res.atts[0].size = (res.atts[0].size/1024/1024).toFixed(2) + 'M'
      //         this.fileList.push(res.atts)
      // } else {
      //
      // }
    },
    // 选择审批人
    selectapprover(e) {
      // lyy
      //   await this.approverFocusSearch();
      //   lyy end
      let _this = this;
      let peo = {
        text: "",
        value: "",
      };
      peo.text = this.approveSaveSubmitIds.map((item) => item.text).join(",");
      peo.value = this.approveSaveSubmitIds.map((item) => item.value).join(",");
      api.getuserInfo().then((res) => {
        // console.log(res);
        let user = [];
        // 存储部门id
        let departmentIds = [];
        res.msg.forEach((d) => {
          user.push(`Member|${d.id}`);
          // 存储
          departmentIds.push(d.orgDepartmentId);
        });

        // console.log("departmentIds", departmentIds);
        // 对部门id去重
        let setDepartmentIds = [...new Set(departmentIds)];
        // console.log("setDepartmentIds", setDepartmentIds);
        parent.$.selectPeople({
          // 授权时的组织机构面板内容
          type: "selectPeople",
          showMe: false,
          panels: "Member,Department",
          selectType: "Member",
          onlyLoginAccount: true,
          onlyCurrentDepartment: false,
          showDepartmentsOfTree: setDepartmentIds.join(","),
          includeElements: user.toString(),
          // isNeedCheckLevelScope: true,//不受职务级别控制
          hiddenPostOfDepartment: true,
          minSize: 0,
          customMaxSize: 3, //最多选择三人
          maxSize: 3, //最多选择三人
          excludeElements: "",
          params: {
            text: peo.text,
            value: peo.value,
          },
          fillBackData: {},
          callback(result) {
            // _this.$set(_this.basicInfo, "manager", result.text);
            // _this.$set(_this.basicInfo, "managerId", result.value.slice(7));
            // console.log("result", result.obj);
            let receiverArr = [];
            _this.msg.approverStr = [];
            _this.approveSaveSubmitIds = [];
            _this.msg.approver = result.value.split(",");
            _this.approverStr = [];
            let ids = [];
            _this.approverOptions = [];
            if (result.obj.length != 0) {
              result.obj.forEach((e) => {
                if (e.type == "Member") {
                  ids.push(e.id);
                } else {
                  _this.approverOptions.push({
                    ...e,
                    value: e.name,
                    operationName: e.name,
                  });
                }
                receiverArr.push(
                  `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`
                );
                _this.approveSaveSubmitIds.push({
                  textName: `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`,
                  text: e.name,
                  value: `${e.type}|${e.id}`,
                });
                _this.approverStr.push(e.id);
              });
              var arr = receiverArr.toString().split(",");
              _this.msg.approverStr.push(...arr);
              //   console.log(
              //     111111111111,
              //     _this.msg.approverStr,
              //     _this.msg.approver
              //   );
              if (ids.length > 0) {
                api.getPeopleMsg({ ids: ids.join(",") }).then((res) => {
                  //   console.log("获取options", res);
                  if (res.code == "1001") {
                    res.msg.forEach((item) => {
                      _this.approverOptions.push({
                        ...item,
                        operationName: `${item.name} (${item.loginName}-${item.department})`,
                        value: item.name + `(${item.department})`,
                      });
                    });
                  }
                });
              }
            } else {
              _this.msg.approver = [];
              _this.msg.approverStr = [];
              _this.approveSaveSubmitIds = [];
              // _this.approverFocusSearch();
            }
            // _this.msg.approver = [];
            // _this.approveSaveSubmitIds = [];
            // // _this.msg.receiversStr = result.text
            // _this.msg.approverStr = [];
            // if (result.obj.length != 0) {
            //   result.obj.forEach((e) => {
            //     receiverArr.push(
            //       `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1] + ")"
            //           : ""
            //       }`
            //     );
            //     // _this.approverOptions.push({
            //     //   ...e,
            //     //   operationName: e.name,
            //     //   value: `${e.name}${
            //     //     e.description && e.description.split("部门:")[1]
            //     //       ? "(" + e.description.split("部门:")[1].trim() + ")"
            //     //       : ""
            //     //   }`,
            //     // });
            //     // // 重置审批人信息内容
            //     _this.approveSaveSubmitIds.push({
            //       textName: `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "( " + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`,
            //       text: e.name,
            //       value: `${e.type}|${e.id}`,
            //     });
            //   });
            //   // _this.msg.approverStr = receiverArr.toString();
            //   // _this.msg.approver = result.value;
            //   // 分隔
            //   var arr4 = receiverArr.toString().split(",");
            //   _this.msg.approverStr.push(...arr4);
            //   let arr5 = new Set(_this.msg.approverStr); //去重
            //   _this.msg.approverStr = [...arr5];
            //   _this.msg.approver = result.value.split(",");
            // }
            e.target.blur();
          },
        });

        //   api.getroleId().then(res =>{
        //
        //     let role
        //     console.log(res)
        //
        //
        //   })
      });
    },
    // 选择收件人与抄送人
    setlepeo(e, n) {
      // console.log( Event)
      if(this.msg.secretlevel == ''){
        this.$message.warning('请先选择邮件密级');
        return;
      }
      let _this = this;
      let peo = {
        text: "",
        value: "",
      };
      if (n == "receivers") {
        peo.text = this.saveSubmitIds.map((item) => item.text).join(",");
        peo.value = this.saveSubmitIds.map((item) => item.value).join(",");
      } else if (n == "copyReceivers") {
        // lyy
        // this.copyReceiversFocusSearch();
        //   lyy end
        peo.text = this.copySaveSubmitIds.map((item) => item.text).join(",");
        peo.value = this.copySaveSubmitIds.map((item) => item.value).join(",");
      }
      else if (n == "secretReceivers") {
        peo.text = this.secretReceiversSaveSubmitIds.map((item) => item.text).join(",");
        peo.value = this.secretReceiversSaveSubmitIds.map((item) => item.value).join(",");
      }

      if (this.searchList) {
        this.searchList.forEach((item, index) => {
          this.msg.receiversStr.forEach((ele) => {
            if (ele.includes(item.name)) {
              this.searchName = item.name;
              this.searchValue = `Member|${item.memberId}`;
            }
          });
        });
      }
      //   console.log("????????????????");
      // peo.text = this.searchName;
      // peo.value = this.searchValue;
      parent.$.selectPeople({
        // 授权时的组织机构面板内容
        type: "selectPeople",
        panels: "Member,Department,Team,Account,Outworker",
        selectType: "Account,Department,Member,Team,Post,Outworker",
        onlyLoginAccount: false,
        // isNeedCheckLevelScope: true,//不受职务级别控制
        minSize: 0,
        maxSize: -1, //
        excludeElements: "",
        hiddenPostOfDepartment: true,
        params: {
          // text:"你好",
          // value:"Member|6428087213914279626"
          text: peo.text,
          value: peo.value,
        },
        accessFileSecretLevel:_this.msg.secretlevel,
        fillBackData: {},
        callback(result) {
          // _this.$set(_this.basicInfo, "manager", result.text);
          // _this.$set(_this.basicInfo, "managerId", result.value.slice(7));
          //   console.log(
          //     "选择人回调方法-------------------------------------",
          //     result,
          //     result.obj
          //   );
          let receiverArr = [];
          if (n == "receivers") {
            _this.msg.receiversStr = [];
            _this.saveSubmitIds = [];
            _this.msg.receivers = result.value.split(",");
            _this.receiversStr = [];
            let ids = [];
            _this.receiversOptions = [];
            if (result.obj.length != 0) {
              result.obj.forEach((e) => {
                if (e.type == "Member") {
                  ids.push(e.id);
                } else {
                  _this.receiversOptions.push({
                    ...e,
                    value: e.name,
                    operationName: e.name,
                  });
                }

                receiverArr.push(
                  `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`
                );

                _this.saveSubmitIds.push({
                  textName: `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`,
                  text: e.name,
                  value: `${e.type}|${e.id}`,
                });
                _this.receiversStr.push(e.id);
                //2022/10/07  _this.receiversStr.push(e.id) 改为name  因为通过选人回显时显示的是id
                // _this.receiversStr.push(e.name);
              });
              console.log('_this.saveSubmitIds',_this.saveSubmitIds);
              var arr = receiverArr.toString().split(",");
              _this.msg.receiversStr.push(...arr);
              //   console.log(
              //     111111111111,
              //     _this.msg.receivers,
              //     _this.msg.receiversStr
              //   );
              if (ids.length > 0) {
                api.getPeopleMsg({ ids: ids.join(",") }).then((res) => {
                  //   console.log("获取options", res);
                  if (res.code == "1001") {
                    if (res.msg.length > 0) {
                      res.msg.forEach((item) => {
                        _this.receiversOptions.push({
                          ...item,
                          operationName: `${item.name} (${item.loginName}-${item.department})`,
                          value: item.name + `(${item.department})`,
                        });
                      });
                    }
                  }
                });
              }
            } else {
              _this.msg.receivers = [];
              _this.msg.receiversStr = [];
              _this.saveSubmitIds = [];
              // _this.focusSearch();
            }
            // _this.msg.receiversStr = [];
            // _this.saveSubmitIds = [];
            // // _this.msg.receiversStr = result.text
            // if (result.obj.length != 0) {
            //   const newArr = [];
            //   result.obj.forEach((e) => {
            //     receiverArr.push(
            //       `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`
            //     );
            //     // 重置收件人信息内容
            //     _this.saveSubmitIds.push({
            //       textName: `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`,
            //       text: e.name,
            //       value: `${e.type}|${e.id}`,
            //     });
            //   });
            //   var arr = receiverArr.toString().split(",");
            //   _this.msg.receiversStr.push(...arr);
            //   let arrrr = new Set(_this.msg.receiversStr);
            //   _this.msg.receiversStr = [...arrrr];
            // _this.msg.receivers = result.value.split(",");
            // 选择抄送人
          } else if (n == "copyReceivers") {
            _this.msg.copyReceiversStr = [];
            _this.copySaveSubmitIds = [];
            _this.msg.copyReceivers = result.value.split(",");
            _this.copyReceiversStr = [];
            let ids = [];
            _this.copyReceiversOptions = [];
            if (result.obj.length != 0) {
              result.obj.forEach((e) => {
                if (e.type == "Member") {
                  ids.push(e.id);
                } else {
                  _this.copyReceiversOptions.push({
                    ...e,
                    value: e.name,
                    operationName: e.name,
                  });
                }
                receiverArr.push(
                  `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`
                );

                _this.copySaveSubmitIds.push({
                  textName: `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`,
                  text: e.name,
                  value: `${e.type}|${e.id}`,
                });
                _this.copyReceiversStr.push(e.id);
              });
              var arr = receiverArr.toString().split(",");
              _this.msg.copyReceiversStr.push(...arr);
              //   console.log(
              //     111111111111,
              //     _this.msg.copyReceivers,
              //     _this.msg.copyReceiversStr,
              //     _this.copyReceiversOptions
              //   );
              if (ids.length > 0) {
                api.getPeopleMsg({ ids: ids.join(",") }).then((res) => {
                  //   console.log("获取options", res);
                  if (res.code == "1001") {
                    res.msg.forEach((item) => {
                      _this.copyReceiversOptions.push({
                        ...item,
                        operationName: `${item.name} (${item.loginName}-${item.department})`,
                        value: item.name + `(${item.department})`,
                      });
                    });
                  }
                });
              }
            } else {
              _this.msg.copyReceivers = [];
              _this.msg.copyReceiversStr = [];
              _this.copySaveSubmitIds = [];
              // _this.copyReceiversFocusSearch();
            }
            // _this.msg.copyReceiversStr = [];
            // _this.copySaveSubmitIds = [];
            // // _this.msg.copyReceiversStr = result.text
            // if (result.obj.length != 0) {
            //   result.obj.forEach((e) => {
            //     // console.log("这是result", e);
            //     receiverArr.push(
            //       `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`
            //     );
            //     // _this.copyReceiversOptions.push({
            //     //   ...e,
            //     //   operationName: e.name,
            //     //   value: `${e.name}${
            //     //     e.description && e.description.split("部门:")[1]
            //     //       ? "(" + e.description.split("部门:")[1].trim() + ")"
            //     //       : ""
            //     //   }`,
            //     // });
            //     // 重置收件人信息内容
            //     _this.copySaveSubmitIds.push({
            //       textName: `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`,
            //       text: e.name,
            //       value: `${e.type}|${e.id}`,
            //     });
            //   });
            //   var arr2 = receiverArr.toString().split(",");
            //   _this.msg.copyReceiversStr.push(...arr2);
            //   let arr3 = new Set(_this.msg.copyReceiversStr);
            //   _this.msg.copyReceiversStr = [...arr3];
            //   _this.msg.copyReceivers = result.value.split(",");
            //   console.log(
            //     "收件人",
            //     _this.msg.copyReceivers,
            //     _this.msg.copyReceiversStr,
            //     _this.copySaveSubmitIds
            //   );
            // } else {
            //   _this.copySaveSubmitIds = [];
            //   _this.msg.copyReceiversStr = [];
            //   _this.msg.copyReceivers = [];
            // }
          }else if (n == "secretReceivers") {
            _this.msg.secretReceiversStr = [];
            _this.secretReceiversSaveSubmitIds = [];
            _this.msg.secretReceivers = result.value.split(",");
            _this.secretReceiversStr = [];
            let ids = [];
            _this.secretReceiversOptions = [];
            if (result.obj.length != 0) {
              result.obj.forEach((e) => {
                if (e.type == "Member") {
                  ids.push(e.id);
                } else {
                  _this.secretReceiversOptions.push({
                    ...e,
                    value: e.name,
                    operationName: e.name,
                  });
                }
                receiverArr.push(
                  `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`
                );

                _this.secretReceiversSaveSubmitIds.push({
                  textName: `${e.name}${
                    e.description && e.description.split("部门:")[1]
                      ? "(" + e.description.split("部门:")[1].trim() + ")"
                      : ""
                  }`,
                  text: e.name,
                  value: `${e.type}|${e.id}`,
                });
                _this.secretReceiversStr.push(e.id);
              });
              var arr = receiverArr.toString().split(",");
              _this.msg.secretReceiversStr.push(...arr);
              //   console.log(
              //     111111111111,
              //     _this.msg.copyReceivers,
              //     _this.msg.copyReceiversStr,
              //     _this.copyReceiversOptions
              //   );
              if (ids.length > 0) {
                api.getPeopleMsg({ ids: ids.join(",") }).then((res) => {
                  //   console.log("获取options", res);
                  if (res.code == "1001") {
                    res.msg.forEach((item) => {
                      _this.secretReceiversOptions.push({
                        ...item,
                        operationName: `${item.name} (${item.loginName}-${item.department})`,
                        value: item.name + `(${item.department})`,
                      });
                    });
                  }
                });
              }
            } else {
              _this.msg.secretReceivers = [];
              _this.msg.secretReceiversStr = [];
              _this.secretReceiversSaveSubmitIds = [];
              // _this.copyReceiversFocusSearch();
            }
            // _this.msg.copyReceiversStr = [];
            // _this.copySaveSubmitIds = [];
            // // _this.msg.copyReceiversStr = result.text
            // if (result.obj.length != 0) {
            //   result.obj.forEach((e) => {
            //     // console.log("这是result", e);
            //     receiverArr.push(
            //       `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`
            //     );
            //     // _this.copyReceiversOptions.push({
            //     //   ...e,
            //     //   operationName: e.name,
            //     //   value: `${e.name}${
            //     //     e.description && e.description.split("部门:")[1]
            //     //       ? "(" + e.description.split("部门:")[1].trim() + ")"
            //     //       : ""
            //     //   }`,
            //     // });
            //     // 重置收件人信息内容
            //     _this.copySaveSubmitIds.push({
            //       textName: `${e.name}${
            //         e.description && e.description.split("部门:")[1]
            //           ? "(" + e.description.split("部门:")[1].trim() + ")"
            //           : ""
            //       }`,
            //       text: e.name,
            //       value: `${e.type}|${e.id}`,
            //     });
            //   });
            //   var arr2 = receiverArr.toString().split(",");
            //   _this.msg.copyReceiversStr.push(...arr2);
            //   let arr3 = new Set(_this.msg.copyReceiversStr);
            //   _this.msg.copyReceiversStr = [...arr3];
            //   _this.msg.copyReceivers = result.value.split(",");
            //   console.log(
            //     "收件人",
            //     _this.msg.copyReceivers,
            //     _this.msg.copyReceiversStr,
            //     _this.copySaveSubmitIds
            //   );
            // } else {
            //   _this.copySaveSubmitIds = [];
            //   _this.msg.copyReceiversStr = [];
            //   _this.msg.copyReceivers = [];
            // }
          }
          

          // 收件人、抄送人 审批验证
          //  <!-- 屏蔽邮件审批  -->
          // _this.emailApproval(false);

          e.target.blur();
        },
      });
    },
    // 获取信息
    getCurPeopleMsg(ids) {
      api.getPeopleMsg({ ids: ids }).then((res) => {
        // console.log("获取options", res);
        if (res.code == "1001") {
          res.msg.forEach((item) => {
            this.receiversOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },
    getCopyCurPeopleMsg(ids) {
      api.getPeopleMsg({ ids: ids }).then((res) => {
        // console.log(res);
        if (res.code == "1001") {
          res.msg.forEach((item) => {
            this.copyReceiversOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },
    getApproverCurPeopleMsg(ids) {
      api.getPeopleMsg({ ids: ids }).then((res) => {
        // console.log(res);
        if (res.code == "1001") {
          res.msg.forEach((item) => {
            this.approverOptions.push({
              ...item,
              operationName: `${item.name} (${item.loginName}-${item.department})`,
              value: item.name + `(${item.department})`,
            });
          });
        }
      });
    },
    // 获取邮件初始数据 xjh
    getdata() {
      let obj = this.$route.query.obj;
      // console.log(obj)
      if (obj == undefined) {
        // 获取签名
        api.getmailSignature().then((res) => {
          this.msg.content = res.msg;
          this.isCrossDisable = false;
        });
        // 编辑
      }
      else if (obj.type == "editMail") {
        api.internalCompile(obj).then((res) => {
          //   console.log("编辑邮件获取的数据", res.msg.bean);
          // console.log(res.msg.attachments[0].icon)
          //   lyy start
          this.msg = res.msg.bean;

          //   console.log("邮件编辑", this.msg);
          // lyy end
          //   lyy 2022 5 30
          let edit = JSON.parse(JSON.stringify(res.msg.bean));
          let receiverIds = [];
          if (edit.receivers) {
            this.receiversOptions = [];
            let curReceivers = edit.receivers.split(",");
            curReceivers.forEach((item, index) => {
              if (item.split("|")[0] == "Member") {
                receiverIds.push(item.split("|")[1]);
              } else {
                // console.log("index", index, edit.receiversStr);
                this.receiversOptions.push({
                  id: item.split("|")[1],
                  value: edit.receiversStr.split(",")[index],
                  operationName: edit.receiversStr.split(",")[index],
                });
              }
            });
            if (receiverIds.length > 0) {
              this.getCurPeopleMsg(receiverIds.join(","));
            }
          } else {
            // this.focusSearch();
          }
          this.receiversStr = edit.receivers
            ? edit.receivers.split(",").map((item) => {
                return item.split("|")[1];
              })
            : [];
          // lyy end
          // 回显收件人数据及id
          this.msg.receiversStr = res.msg.bean.receiversStr
            ? res.msg.bean.receiversStr.split(",")
            : [];
          this.msg.receivers = res.msg.bean.receivers
            ? res.msg.bean.receivers.split(",")
            : [];

          //   console.log(
          //     "this.msg.receivers",
          //     this.msg.receivers,
          //     this.msg.receiversStr,
          //     this.receiversStr
          //   );
          for (
            let receiversIndex = 0, length = this.msg.receiversStr.length;
            receiversIndex < length;
            receiversIndex++
          ) {
            // 收件人信息集合
            this.saveSubmitIds.push({
              text: this.msg.receiversStr[receiversIndex],
              value: this.msg.receivers[receiversIndex],
            });
          }

          //   lyy 2022 5 30
          //   console.log("edit", edit);
          let copyReceiverIds = [];
          this.copyReceiversOptions = [];
          if (edit.copyReceivers) {
            let curCopyReceivers = [...edit.copyReceivers.split(",")];
            // console.log(curCopyReceivers);
            curCopyReceivers.forEach((item, index) => {
              if (item.split("|")[0] == "Member") {
                copyReceiverIds.push(item.split("|")[1]);
              } else {
                // console.log(111, index, edit.copyReceiversStr);
                this.copyReceiversOptions.push({
                  id: item.split("|")[1],
                  value: edit.copyReceiversStr.split(",")[index],
                  operationName: edit.copyReceiversStr.split(",")[index],
                });
                // console.log(111, this.copyReceiversOptions);
              }
            });
            if (copyReceiverIds.length > 0) {
              this.getCopyCurPeopleMsg(copyReceiverIds.join(","));
            }
          } else {
            // this.copyReceiversFocusSearch();
          }
          // this.copyReceiversStr = res.msg.bean.copyReceiversStr
          //   ? res.msg.bean.copyReceiversStr.split(",")
          //   : [];
          this.copyReceiversStr = edit.copyReceivers
            ? edit.copyReceivers.split(",").map((item) => {
                return item.split("|")[1];
              })
            : [];
          // lyy end
          // 回显抄送人数据及id
          this.msg.copyReceiversStr = res.msg.bean.copyReceiversStr
            ? res.msg.bean.copyReceiversStr.split(",")
            : [];
          this.msg.copyReceivers = res.msg.bean.copyReceivers
            ? res.msg.bean.copyReceivers.split(",")
            : [];

          for (
            let copyReceiversIndex = 0,
              length = this.msg.copyReceiversStr.length;
            copyReceiversIndex < length;
            copyReceiversIndex++
          ) {
            // 收件人信息集合
            this.copySaveSubmitIds.push({
              text: this.msg.copyReceiversStr[copyReceiversIndex],
              value: this.msg.copyReceivers[copyReceiversIndex],
            });
          }

          //   lyy 2022 5 30
          //   console.log("edit", edit);
          // let appoverReceiverIds = [];
          // this.approverOptions = [];
          // if (edit.approver) {
          //   let curAppoverReceivers = [...edit.approver.split(",")];
          //   // console.log(curAppoverReceivers);
          //   curAppoverReceivers.forEach((item, index) => {
          //     appoverReceiverIds.push(item.split("|")[1]);
          //   });
          //   if (appoverReceiverIds.length > 0) {
          //     this.getApproverCurPeopleMsg(appoverReceiverIds.join(","));
          //   }
          // } else {
          //   // this.approverFocusSearch();
          // }
          // this.approverStr = edit.approver
          //   ? edit.approver.split(",").map((item) => {
          //       return item.split("|")[1];
          //     })
          //   : [];
          // // lyy end
          // // 回显审批人数据及id
          // this.msg.approverStr = res.msg.bean.approverStr
          //   ? res.msg.bean.approverStr.split(",")
          //   : [];
          // this.msg.approver = res.msg.bean.approver
          //   ? res.msg.bean.approver.split(",")
          //   : [];

          // for (
          //   let approverIndex = 0, length = this.msg.approverStr.length;
          //   approverIndex < length;
          //   approverIndex++
          // ) {
          //   // 收件人信息集合
          //   this.approveSaveSubmitIds.push({
          //     text: this.msg.approverStr[approverIndex],
          //     value: this.msg.approver[approverIndex],
          //   });
          // }

          // this.msg.kuaWang = res.msg.bean.kuaWang;
          // this.msg.kuaWangdis = res.msg.isCrossDisable;
          // this.msg.secretTypeId = this.$route.query.obj.secretTypeId;
          this.msg.affairId = res.msg.affairId;
          // this.isCrossDisable = res.msg.isCrossDisable;
          this.msg.editMailSend = this.$route.query.obj.editMailSend;
          this.secretReceiversStr = res.msg.bean.secretReceiversStr
            ? res.msg.bean.secretReceiversStr.split(",")
            : [];
          this.msg.secretReceiversStr = res.msg.bean.secretReceiversStr
            ? res.msg.bean.secretReceiversStr.split(",")
            : [];
          this.msg.secretReceivers = res.msg.bean.secretReceivers
            ? res.msg.bean.secretReceivers.split(",")
            : [];
          for (
            let secretReceiversIndex = 0, length = this.msg.secretReceiversStr.length;
            secretReceiversIndex < length;
            secretReceiversIndex++
          ) {
            // 密送人信息集合
            this.secretReceiversSaveSubmitIds.push({
              text: this.msg.secretReceiversStr[secretReceiversIndex],
              value: this.msg.secretReceivers[secretReceiversIndex],
            });
          }
          if(this.msg.secretLevel){
            this.fileSecret = this.mailSecret.filter(item=>{
              return this.msg.secretLevel >= item.sort
            })
          }
          console.log("this.msg.receivers", this.msg.receivers,this.msg.secretReceiversStr,this.secretReceiversStr);
          this.$set(this.msg, 'secretlevel', res.msg.bean.secretLevel + '');
          console.log('this.mailSecret',this.mailSecret);
          console.log('this.msg.secretLevel',this.msg.secretLevel);
          if (res.msg.attachments.length != 0) {
            // this.fileList = res.msg.attachments;
            res.msg.attachments.forEach((i) => {
              i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
              this.fileList.push(i);
            });
            this.$nextTick();
          }
        });
        // 回复
      }
      else if (obj.type == "replyMail") {
        let receiverslist;
        let arr = [];
        if (obj.mark == "allReply") {
          api.allreplyMailinfo(obj).then((res) => {
            console.log("res``", res);
            this.msg = res.msg.bean;

            receiverslist = this.msg.receiversDetail.split(",");

            receiverslist.some((d, i) => {
              receiverslist[i] = d.split("-");
            });
            // console.log(res);

            receiverslist.forEach((d) => {
              //   console.log("收件人", d);
              if (
                d[0] === "Department" ||
                d[0] === "Team" ||
                d[0] === "Account"
              ) {
                arr.push(`${d[1]}`);
              } else {
                arr.push(`${d[1]}(${d[3]})`);
              }
            });

            console.log('receiverslist---', receiverslist)

            //   lyy 2022 5 30
            // console.log(res.msg.bean.receiversStr);
            let edit = JSON.parse(JSON.stringify(res.msg.bean));
            let receiverIds = [];
            this.receiversOptions = [];
            if (edit.receivers) {
                console.log("edit.receivers", edit.receivers);
                console.log('edit.receiversStr', edit.receiversStr)
              let curReceivers = edit.receivers.split(",");
                console.log('curReceivers---', curReceivers)

              curReceivers.forEach((item, index) => {
                if (item.split("|")[0] == "Member") {
                  receiverIds.push(item.split("|")[1]);
                } else {
                  //   console.log("index", index, edit.receiversStr);
                  this.receiversOptions.push({
                    id: item.split("|")[1],
                    value: edit.receiversStr.split(",")[index],
                    operationName: edit.receiversStr.split(",")[index],
                  });
                }
              });
              // console.log(this.receiversOptions)

              if (receiverIds.length > 0) {
                this.getCurPeopleMsg(receiverIds.join(","));
              }
            }
            else {
              // this.focusSearch();
            }
            this.receiversStr = edit.receivers
              ? edit.receivers.split(",").map((item) => {
                  return item.split("|")[1];
                })
              : [];
            // lyy end
            this.msg.receiversStr = arr;
            // console.log(arr);

            this.msg.kuaWang = res.msg.bean.kuaWang;
            this.msg.secretTypeId = this.$route.query.obj.secretTypeId;
            this.msg.affairId = res.msg.affairId;
            this.isCrossDisable = res.msg.isCrossDisable;
            // console.log(`res.msg.isCrossDisable`, res.msg.isCrossDisable);
            this.msg.kuaWangdis = res.msg.isCrossDisable;

            if (res.msg.attachments && res.msg.attachments.length != 0) {
              //   this.fileList = res.msg.attachments;
              res.msg.attachments.forEach((i) => {
                i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
                this.fileList.push(i);
              });
            }
            // 回显收件人数据及id
            // this.msg.receiversStr = res.msg.bean.receiversStr
            //   ? res.msg.bean.receiversStr.split(",")
            //   : [];

            this.msg.receivers = res.msg.bean.receivers
              ? res.msg.bean.receivers.split(",")
              : [];
            // console.log("this.msg.receivers", this.msg.receivers);
            for (
              let receiversIndex = 0, length = arr.length;
              receiversIndex < length;
              receiversIndex++
            ) {
              // 收件人信息集合
              this.saveSubmitIds.push({
                text: arr[receiversIndex],
                value: this.msg.receivers[receiversIndex],
              });
            }
            //   lyy 2022 5 30
            //   console.log("edit", edit);
            let copyReceiverIds = [];
            this.copyReceiversOptions = [];
            if (edit.copyReceivers) {
              let curCopyReceivers = [...edit.copyReceivers.split(",")];
              // console.log(curCopyReceivers);
              curCopyReceivers.forEach((item, index) => {
                if (item.split("|")[0] == "Member") {
                  copyReceiverIds.push(item.split("|")[1]);
                } else {
                  // console.log(111, index, edit.copyReceiversStr);
                  this.copyReceiversOptions.push({
                    id: item.split("|")[1],
                    value: edit.copyReceiversStr.split(",")[index],
                    operationName: edit.copyReceiversStr.split(",")[index],
                  });
                  // console.log(111, this.copyReceiversOptions);
                }
              });
              if (copyReceiverIds.length > 0) {
                this.getCopyCurPeopleMsg(copyReceiverIds.join(","));
              }
            } else {
              // this.copyReceiversFocusSearch();
            }
            this.copyReceiversStr = edit.copyReceivers
              ? edit.copyReceivers.split(",").map((item) => {
                  return item.split("|")[1];
                })
              : [];
            // lyy end
            // 回显抄送人数据及id
            this.msg.copyReceiversStr = res.msg.bean.copyReceiversStr
              ? res.msg.bean.copyReceiversStr.split(",")
              : [];
            this.msg.copyReceivers = res.msg.bean.copyReceivers
              ? res.msg.bean.copyReceivers.split(",")
              : [];

            for (
              let copyReceiversIndex = 0,
                length = this.msg.copyReceiversStr.length;
              copyReceiversIndex < length;
              copyReceiversIndex++
            ) {
              // 收件人信息集合
              this.copySaveSubmitIds.push({
                text: this.msg.copyReceiversStr[copyReceiversIndex],
                value: this.msg.copyReceivers[copyReceiversIndex],
              });
            }
          //   this.secretReceiversStr = res.msg.bean.secretReceiversStr
          //   ? res.msg.bean.secretReceiversStr.split(",")
          //   : [];
          //   this.msg.secretReceiversStr = res.msg.bean.secretReceiversStr
          //     ? res.msg.bean.secretReceiversStr.split(",")
          //     : [];
          //   this.msg.secretReceivers = res.msg.bean.secretReceivers
          //     ? res.msg.bean.secretReceivers.split(",")
          //     : [];
          //     for (
          //   let secretReceiversIndex = 0, length = this.msg.secretReceiversStr.length;
          //   secretReceiversIndex < length;
          //   secretReceiversIndex++
          // ) {
          //   // 密送人信息集合
          //   this.secretReceiversSaveSubmitIds.push({
          //     text: this.msg.secretReceiversStr[secretReceiversIndex],
          //     value: this.msg.secretReceivers[secretReceiversIndex],
          //   });
          // }
              // 回复和回复全部不需要回显密送人
              this.msg.secretReceivers = [];
              this.msg.secretReceiversStr = [];
              this.secretReceiversStr = [];
              console.log("this.msg.receivers", this.msg.receivers,this.msg.secretReceiversStr,this.secretReceiversStr);
              this.$set(this.msg, 'secretlevel', res.msg.bean.secretLevel + '');
              console.log('this.mailSecret',this.mailSecret);
              console.log('this.msg.secretLevel',this.msg.secretLevel);

            // 回显审批人数据及id
            // this.msg.approverStr = res.msg.bean.approverStr
            //   ? res.msg.bean.approverStr.split(",")
            //   : [];
            // this.msg.approver = res.msg.bean.approver
            //   ? res.msg.bean.approver.split(",")
            //   : [];

            // for (
            //   let approverIndex = 0, length = this.msg.approverStr.length;
            //   approverIndex < length;
            //   approverIndex++
            // ) {
            //   // 收件人信息集合
            //   this.approveSaveSubmitIds.push({
            //     text: this.msg.approverStr[approverIndex],
            //     value: this.msg.approver[approverIndex],
            //   });
            // }
          });
        }
        else {
          api.replyMailinfo(obj).then((res) => {
            //   lyy start
            // this.msg = res.msg.bean;
            // console.log("res.msg.bean``", res.msg.bean);
            this.msg = {
              ...res.msg.bean,
              copyReceiversStr: res.msg.bean.copyReceiversStr.split(","),
              receiversStr: res.msg.bean.receiversStr.split(","),
              // approverStr: res.msg.bean.approverStr.split(","),
              // approver: res.msg.bean.approver.split(","),
              receivers: res.msg.bean.receivers.split(","),
              copyReceivers: res.msg.bean.copyReceivers.split(","),
            };
            // lyy end
            receiverslist = this.msg.receiversDetail.split(",");

            receiverslist.some((d, i) => {
              receiverslist[i] = d.split("-");
            });
            // console.log(res);

            receiverslist.forEach((d) => {
              if (
                d[0] === "Department" ||
                d[0] === "Team" ||
                d[0] === "Account"
              ) {
                arr.push(`${d[1]}`);
              } else {
                arr.push(`${d[1]}(${d[3]})`);
              }
            });
            //   lyy 2022 5 30
            let edit = JSON.parse(JSON.stringify(res.msg.bean));
            let receiverIds = [];
            if (edit.receivers) {
              this.receiversOptions = [];
              let curReceivers = edit.receivers.split(",");
              curReceivers.forEach((item, index) => {
                if (item.split("|")[0] == "Member") {
                  receiverIds.push(item.split("|")[1]);
                } else {
                  // console.log("index", index, edit.receiversStr);
                  this.receiversOptions.push({
                    id: item.split("|")[1],
                    value: edit.receiversStr.split(",")[index],
                    operationName: edit.receiversStr.split(",")[index],
                  });
                }
              });
              this.getCurPeopleMsg(receiverIds.join(","));
            } else {
              // this.focusSearch();
            }
            this.receiversStr = edit.receivers
              ? edit.receivers.split(",").map((item) => {
                  return item.split("|")[1];
                })
              : [];
            // lyy end
            this.msg.receiversStr = arr;
            this.msg.kuaWang = res.msg.bean.kuaWang;
            this.msg.secretTypeId = this.$route.query.obj.secretTypeId;
            this.msg.affairId = res.msg.affairId;
            this.isCrossDisable = res.msg.isCrossDisable;
            // console.log(`res.msg.isCrossDisable`, res.msg.isCrossDisable);
            this.msg.kuaWangdis = res.msg.isCrossDisable;

            if (res.msg.attachments && res.msg.attachments.length != 0) {
              //   this.fileList = res.msg.attachments;
              res.msg.attachments.forEach((i) => {
                i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
                this.fileList.push(i);
              });
            }

            // 回显收件人数据及id
            // this.msg.receiversStr = res.msg.bean.receiversStr
            //   ? res.msg.bean.receiversStr.split(",")
            //   : [];
            this.msg.receivers = res.msg.bean.receivers
              ? res.msg.bean.receivers.split(",")
              : [];
            // console.log("this.msg.receivers", this.msg.receivers);
            for (
              let receiversIndex = 0, length = arr.length;
              receiversIndex < length;
              receiversIndex++
            ) {
              // 收件人信息集合
              this.saveSubmitIds.push({
                text: arr[receiversIndex],
                value: this.msg.receivers[receiversIndex],
              });
            }
            // 回显抄送人数据及id
            this.msg.copyReceiversStr = res.msg.bean.copyReceiversStr
              ? res.msg.bean.copyReceiversStr.split(",")
              : [];
            this.msg.copyReceivers = res.msg.bean.copyReceivers
              ? res.msg.bean.copyReceivers.split(",")
              : [];
            for (
              let copyReceiversIndex = 0,
                length = this.msg.copyReceiversStr.length;
              copyReceiversIndex < length;
              copyReceiversIndex++
            ) {
              // 收件人信息集合
              this.copySaveSubmitIds.push({
                text: this.msg.copyReceiversStr[copyReceiversIndex],
                value: this.msg.copyReceivers[copyReceiversIndex],
              });
            }
          //   this.secretReceiversStr = res.msg.bean.secretReceiversStr
          //   ? res.msg.bean.secretReceiversStr.split(",")
          //   : [];
          //   this.msg.secretReceiversStr = res.msg.bean.secretReceiversStr
          //     ? res.msg.bean.secretReceiversStr.split(",")
          //     : [];
          //   this.msg.secretReceivers = res.msg.bean.secretReceivers
          //     ? res.msg.bean.secretReceivers.split(",")
          //     : [];
          //        this.copyReceiversStr = res.msg.bean.copyReceiversStr
          //   ? res.msg.bean.copyReceiversStr.split(",")
          //   : [];
          //   for (
          //   let secretReceiversIndex = 0, length = this.msg.secretReceiversStr.length;
          //   secretReceiversIndex < length;
          //   secretReceiversIndex++
          // ) {
          //   // 密送人信息集合
          //   this.secretReceiversSaveSubmitIds.push({
          //     text: this.msg.secretReceiversStr[secretReceiversIndex],
          //     value: this.msg.secretReceivers[secretReceiversIndex],
          //   });
          // }
            // 回复和回复全部不需要回显密送人
            this.msg.secretReceivers = [];
            this.msg.secretReceiversStr = [];
            this.secretReceiversStr = [];
            console.log("this.msg.receivers", this.msg.receivers,this.msg.secretReceiversStr,this.secretReceiversStr);
            this.$set(this.msg, 'secretlevel', res.msg.bean.secretLevel + '');
            console.log('this.mailSecret',this.mailSecret);
            console.log('this.msg.secretLevel',this.msg.secretLevel);

            // 回显审批人数据及id
            // this.msg.approverStr = res.msg.bean.approverStr
            //   ? res.msg.bean.approverStr.split(",")
            //   : [];
            // this.msg.approver = res.msg.bean.approver
            //   ? res.msg.bean.approver.split(",")
            //   : [];

            // for (
            //   let approverIndex = 0, length = this.msg.approverStr.length;
            //   approverIndex < length;
            //   approverIndex++
            // ) {
            //   // 收件人信息集合
            //   this.approveSaveSubmitIds.push({
            //     text: this.msg.approverStr[approverIndex],
            //     value: this.msg.approver[approverIndex],
            //   });
            // }
          });
        }
        // 转发
      }
      else if (obj.type == "forwordMail") {
        // console.log(obj);
        this.selectmj = true;
        api.forwordMail(obj).then((res) => {
          // console.log("转发", res);
          //  lyy start
          //   this.msg = res.msg.bean;

          this.msg = {
            ...res.msg.bean,
            copyReceiversStr: [],
            receiversStr: [],
            approverStr: [],
            approver: [],
            receivers: [],
            copyReceivers: [],
            // 转发密送滞空
            secretReceiversStr:[],
            secretReceivers:[]
          };
          console.log("转发", this.msg);
          //   lyy end
          this.msg.kuaWang = res.msg.bean.kuaWang;
          this.msg.secretTypeId = this.$route.query.obj.secretTypeId;
          this.msg.affairId = res.msg.affairId;
          this.isCrossDisable = res.msg.isCrossDisable;
          // 转发邮件时，密级类型非公开和内部需要 可跨网，其他类型是禁用掉 modify yangyanhua20210908
          this.msg.kuaWangdis = res.msg.isCrossDisable;
          this.$set(this.msg, 'secretlevel', res.msg.bean.secretLevel + '');

          if (res.msg.attachments && res.msg.attachments.length != 0) {
            //lyy start
            res.msg.attachments.forEach((i) => {
              i.size = (i.size / 1024 / 1024).toFixed(2) + "M";
              this.fileList.push(i);
            });
            // this.fileList = res.msg.attachments;
            // lyy end
          }
        });
      }

      let params = {
        type: "",
        secretId: "",
      };
      if (obj == undefined) {
        params.type = "";
        params.secretId = "";
      } else {
        params.type = this.$route.query.obj.type;
        params.secretId = this.$route.query.obj.secretTypeId;
      }
      //   console.log(params);
      // if (this.$store.state.isredNet) {
      //   // api.getSecretList(params).then((res) => {
      //   //   this.secretTypeIdList = res.msg;
      //   //   if (obj == undefined) {
      //   //     // this.msg.secretTypeId = this.secretTypeIdList[0].id
      //   //     // console.log(this.msg.secretTypeId);
      //   //   } else {
      //   //     this.msg.secretTypeId = this.$route.query.obj.secretTypeId;
      //   //   }
      //   // });
      //   //先注释MailFileSecretVerify 校验文件密级
      //   // api.MailFileSecretVerify({secret:this.msg.secretTypeId}).then(res =>{
      //   //   console.log(res)
      //   //   if (res.code != 10001){
      //   //     this.$nextTick().then(() => {
      //   //       this.msg.secretTypeId = this.secretTypeIdold
      //
      //   //     });
      //
      //   //     this.$message.error(res.msg)
      //
      //   //   }
      //   //   else {
      //
      //   //     // this.fileList = []
      //   //     let obj ={
      //   //       secretTypeId:this.msg.secretTypeId,
      //   //       fileNames:[]
      //   //     }
      //   //     this.fileList.forEach( d =>{
      //   //       obj.fileNames.push(d.filename)
      //   //     })
      //   //     obj.fileNames=obj.fileNames.toString()
      //
      //   //     api.isSecret(obj).then(res =>{
      //
      //   //       this.$nextTick().then(() => {
      //   //         this.msg.kuaWangdis=res.msg.isSecret
      //   //         console.log('---------------------------------------------------')
      //   //         console.log(this.msg.kuaWangdis)
      //   //         this.$forceUpdate()
      //
      //   //       });
      //
      //   //       if (res.code == 10001){
      //   //         if(res.msg.isSecret == true){
      //   //           // this.$message.warning("涉密邮件不可跨网")
      //   //           this.msg.kuaWang = false
      //   //           this.msg.kuaWangdis = true
      //   //           // this.secretTypeIdold = this.msg.secretTypeId
      //   //         }
      //   //       }else {
      //
      //   //         this.$message.warn(res.msg)
      //   //       }
      //
      //   //     })
      //   //     // if (this.msg.secretTypeId == -637209554414910365){
      //   //     //     this.$message.warning("涉密邮件不可跨网")
      //   //     //     this.msg.kuaWang = false
      //   //     // }
      //   //   }
      //
      //   // })
      // }
      //   console.log(this.isCrossDisable);
    },
    //点击邮件转发需要修改面板布局，隐藏邮件列表
    lxryc() {
      this.sendtie = false;
      // this.$store.commit('showlxr', [0, 24],);
      //点击邮件转发需要修改面板布局，隐藏邮件列表
      if (
        document.querySelector(".mid") &&
        document.querySelector(".mid").style.display == ""
      ) {
        document.querySelector(".mid").style.display = "none";
      }
      if (
        document.querySelector(".resize") &&
        document.querySelector(".resize").style.display == ""
      ) {
        document.querySelector(".resize").style.display = "none";
      }
      if (
        document.querySelector(".right") &&
        document.querySelector(".right").style.width == ""
      ) {
        document.querySelector(".right").style.width = "auto";
      }
    },

    //  富文本

    onEditorBlur() {
      //失去焦点事件
    },
    onEditorFocus() {
      //获得焦点事件
    },
    // 开始
    onEditorReady(editor) {},

    onEditorChange() {
      //内容改变事件
      this.$emit("input", this.content);
    },

    // 富文本图片上传前
    beforeUpload() {
      // 显示loading动画
      this.quillUpdateImg = true;
    },

    uploadSuccess(res, file) {
      // res为图片服务器返回的数据
      // 获取富文本组件实例
      let quill = this.$refs.myQuillEditor.quill;
      // 如果上传成功
      if (res.atts.length != 0) {
        // 获取光标所在位置
        let length = quill.getSelection().index;
        // 插入图片  res.url为服务器返回的图片地址  res.result.url为图片地址
        quill.insertEmbed(
          length,
          "image",
          `/seeyon/fileUpload.do?method=showRTE&fileId=${encodeURI(
            res.atts[0].fileUrl
          )}&createDate=${res.atts[0].createdate.slice(
            0,
            10
          )}&type=image&showType=big`
        );
        // 调整光标到最后
        quill.setSelection(length + 1);
      } else {
        this.$message.error("图片插入失败");
      }
      // loading动画消失
      this.quillUpdateImg = false;
    },
    // 富文本图片上传失败
    uploadError() {
      // loading动画消失
      this.quillUpdateImg = false;
      this.$message.error("图片插入失败");
    },
  },
};
</script>

<style scoped>
.uploadflie {
  max-height: 150px;

  overflow-y: scroll;
}

/* *解决多选自动换行  
.select-user-form /deep/ .el-select__tags { 
   flex-wrap: unset; 
   overflow: auto;
   margin-left: 5px;
} */
/* 取消保存改为 X  start*/
.demo-form-inline .closeBt {
  position: absolute;
  right: 0;
  border: none;
  font-size: 13px;
  padding: 2px 5px !important;
}
.demo-form-inline .closeBt:hover {
  background-color: #f78989;
  border-radius: 3px !important;
  color: #fff;
  scale: 1.2;
  transition: all 0.2s;
}
/* 取消保存改为 X  end*/
.the-theme {
  margin-bottom: 10px;
}

.copy-people .the-recipient {
  display: block !important;
}

.secretArrow /deep/ .el-input__suffix {
  display: flex;
  align-items: center;
}

.approver,
.recipient,
.copyReceiver,
.select-user,
.approver {
  display: block !important;
}

.theme /deep/ .el-form-item__label {
  margin-top: 5px !important;
}

.select-user-form {
  position: relative;
  text-align: center;
  min-height: 40px !important;
  line-height: 40px !important;
}

.select-user-form .position-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  color: #c0c4cc;
}

.count /deep/ .el-select .el-select-dropdown {
  z-index: 1000 !important;
}

.count /deep/ .el-select .el-input .el-input__inner {
  box-sizing: border-box;
}

.select-user /deep/ .el-select__input {
  border: none !important;
}

.el-select /deep/ .el-input:hover {
  background-color: transparent;
  border: none;
}

/**tangxiangping 📅：2022-06-02 修改elementUI自带display： contents不兼容低版本浏览器的问题  start*/
.el-select /deep/ .el-select__tags > span {
  display: flex;
  flex-wrap: wrap;
}
/**tangxiangping 📅：2022-06-02 修改elementUI自带display： contents不兼容低版本浏览器的问题  end*/

.el-select-dropdown.is-multiple .el-select-dropdown__item.selected {
  font-weight: 400;
}
.el-select-dropdown__list .el-select-dropdown__item{
  text-align: left !important;
}
.item:hover {
  background-color: #ffffff !important;
}

.select-user /deep/ .el-input .el-select__caret::before {
  content: "";
}

.count {
  /*padding: 15px;*/
  background: #f7f8f9;
  /* height: 100%;
  overflow: auto; */
  /* lyy start */
  height: 100vh;
  overflow: hidden;
}

.count /deep/ .el-form-item {
  margin-bottom: 10px;
}

/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background-color: #f5f5f5;
}

/*定义滚动条轨道 内阴影+圆角*/
::-webkit-scrollbar-track {
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  background-color: #f5f5f5;
}

/*定义滑块 内阴影+圆角*/
::-webkit-scrollbar-thumb {
  border-radius: 10px;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
  -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
  background-color: #c8c8c8;
}
</style>
